Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .flake8

This file was deleted.

10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ jobs:
run: python -m pip install -r requirements-dev.txt
- name: Install Node.js dependencies
run: npm ci --ignore-scripts
- name: Run Black
run: black --check .
- name: Run isort
run: isort --check-only .
- name: Run Flake8
run: flake8 .
- name: Run Ruff lint
run: ruff check .
- name: Check Python formatting
run: ruff format --check .
- name: Run djLint
run: djlint templates/ --check --profile=jinja
- name: Run static asset checks
Expand Down
9 changes: 0 additions & 9 deletions .isort.cfg

This file was deleted.

19 changes: 5 additions & 14 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
exclude: ^(\.pytest_cache|\.pytest-tmp)/

repos:
- repo: https://github.com/psf/black
rev: 25.1.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.9
hooks:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/isort
rev: 6.0.1
hooks:
- id: isort
language_version: python3
- repo: https://github.com/pycqa/flake8
rev: 7.3.0
hooks:
- id: flake8
language_version: python3
- id: ruff
args: [--fix]
- id: ruff-format
- repo: https://github.com/Riverside-Healthcare/djLint
rev: v1.36.4
hooks:
Expand Down
14 changes: 5 additions & 9 deletions FORMATTERS_AND_LINTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ This project enforces consistent code style and quality across Python, Jinja tem

| Tool | Purpose | Config File | Notes |
|---------|----------------------------------------------|---------------------|-------|
| Black | Code formatter for Python | `pyproject.toml` | Enforces PEP 8 style, auto-formats code |
| isort | Sorts and organizes Python imports | `.isort.cfg` | Keeps imports grouped and ordered |
| Flake8 | Linter for Python code quality | `.flake8` | Reports style and logic issues |
| Ruff | Python linter, import sorter, and formatter | `pyproject.toml` | Replaces Flake8, isort, and Black |
| djlint | Formatter/linter for Jinja templates | `.djlintrc` | Only runs on `.jinja` files |

**Exclusions:** The `migrations/` folder is excluded from all Python formatters/linters to avoid altering migration scripts.
Expand All @@ -33,7 +31,7 @@ All static asset tools are managed via `package.json` (see `devDependencies` and
## Automation

- **Pre-commit hooks**: `.pre-commit-config.yaml` runs all formatters and linters automatically on commit for Python, Jinja, JS, and CSS files.
- Python: Black, isort, Flake8
- Python: Ruff lint and format hooks
- Jinja: djlint (only on `.jinja` files)
- JS/CSS: Prettier, ESLint, Stylelint (via npm scripts)

Expand Down Expand Up @@ -68,8 +66,8 @@ All static asset tools are managed via `package.json` (see `devDependencies` and

### Python/Jinja
- Install dev tools: `pip install -r requirements-dev.txt`
- Format code: `black .` and `isort .`
- Lint code: `flake8 .`
- Format code: `ruff check --fix .` and `ruff format .`
- Lint code: `ruff check .`
- Format/lint Jinja: `djlint templates/ --reformat --profile=jinja`

### JavaScript/CSS
Expand Down Expand Up @@ -101,9 +99,7 @@ All static asset tools are managed via `package.json` (see `devDependencies` and
---

## References
- [Black](https://black.readthedocs.io/)
- [isort](https://pycqa.github.io/isort/)
- [Flake8](https://flake8.pycqa.org/)
- [Ruff](https://docs.astral.sh/ruff/)
- [djlint](https://djlint.com/)
- [ESLint](https://eslint.org/)
- [Stylelint](https://stylelint.io/)
Expand Down
6 changes: 4 additions & 2 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,13 @@ def get_expired_comparisons(retention_days: int):
expired_ids = []

# Get all comparisons with their expiration settings
comparisons = query(("""
comparisons = query((
"""
SELECT id, expiration_type, expiration_days, created_at,
last_accessed, never_expire
FROM comparisons
"""))
"""
))
print(f"Checking for expired comparisons with retention_days={retention_days}")
num = len(comparisons)
print(f"Found {num} comparisons to check for expiration")
Expand Down
26 changes: 20 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,27 @@ authors = [

requires-python = ">=3.13"

[tool.black]
[tool.ruff]
line-length = 100
target-version = ['py38']
include = '\.pyi?$'
exclude = '''
/(\.pytest_cache|\.pytest-tmp|venv|env|\.venv|static|templates|migrations|node_modules)/
'''
target-version = "py313"
extend-exclude = [
".pytest_cache",
".pytest-tmp",
"venv",
"env",
"static",
"templates",
"migrations",
"node_modules",
]
force-exclude = true

[tool.ruff.lint]
select = ["E", "F", "W", "I"]
ignore = ["E203"]

[tool.ruff.lint.isort]
known-first-party = ["api"]

[tool.pytest.ini_options]
addopts = "--strict-markers --strict-config --basetemp=.pytest-tmp"
Expand Down
4 changes: 1 addition & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Development requirements for formatting, linting and tests
black==26.5.1
isort==8.0.1
flake8==7.4.1
ruff==0.16.9
djlint==1.44.2
pre-commit==4.6.2
setuptools==84.0.0
Expand Down
5 changes: 2 additions & 3 deletions scripts/check_format_lint.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ echo.
echo =============================
echo Checking Python files
echo =============================
black --check .
isort --check-only .
flake8 .
ruff check .
ruff format --check .

echo.
echo =============================
Expand Down
5 changes: 2 additions & 3 deletions scripts/check_format_lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ echo
echo "============================="
echo " Checking Python files"
echo "============================="
black --check .
isort --check-only .
flake8 .
ruff check .
ruff format --check .

echo
echo "============================="
Expand Down
6 changes: 3 additions & 3 deletions scripts/format_all.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ echo.
echo =============================
echo Formatting Python files
echo =============================
black .
isort .
flake8 .
ruff check --fix .
ruff format .
ruff check .

echo.
echo =============================
Expand Down
6 changes: 3 additions & 3 deletions scripts/format_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ echo
echo "============================="
echo " Formatting Python files"
echo "============================="
black .
isort .
flake8 .
ruff check --fix .
ruff format .
ruff check .

echo
echo "============================="
Expand Down
4 changes: 2 additions & 2 deletions scripts/migrate_sqlite_to_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _reset_sequences(
continue
# seq is like 'public.users_id_seq'
execute_fn(
(f"SELECT setval('{seq}', " f"(SELECT COALESCE(MAX(id), 1) FROM {tbl}), true)"),
(f"SELECT setval('{seq}', (SELECT COALESCE(MAX(id), 1) FROM {tbl}), true)"),
(),
)

Expand Down Expand Up @@ -135,7 +135,7 @@ def migrate(sqlite_path: str, pg_url: str, wipe_target: bool = False):
# Point adapter at Postgres and ensure schema
os.environ["DB_BACKEND"] = "postgres"
os.environ["DATABASE_URL"] = pg_url
# Import app modules lazily (after sys.path and env are set) to satisfy flake8 E402
# Import app modules lazily (after sys.path and env are set) to satisfy Ruff E402
import database # type: ignore # noqa: WPS433
from db import backend_name as _backend_name # type: ignore # noqa: WPS433
from db import execute as _execute
Expand Down
Loading