Skip to content

Add Python linting & type-checking tooling (ruff + mypy/django-stubs), slim pylint, apply safe auto-fixes#1587

Open
davmlaw wants to merge 1 commit into
masterfrom
fable_python_types
Open

Add Python linting & type-checking tooling (ruff + mypy/django-stubs), slim pylint, apply safe auto-fixes#1587
davmlaw wants to merge 1 commit into
masterfrom
fable_python_types

Conversation

@davmlaw

@davmlaw davmlaw commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

🤖 Written by Claude

Addresses #1586.

Tooling

  • mypy + django-stubs + djangorestframework-stubsmypy.ini, gradual config with a per-app strictness ratchet (start snpdb).
  • ruffruff.toml, fast linter + formatter coexisting with pylint (owns style/imports/modernization).
  • pylint slimmedconfig/pylint3.rc keeps only inference-heavy E-checks + pylint_django; ruff owns the rest.
  • format_code.shautopep8ruff check --fix.
  • requirements — add ruff, mypy, django-stubs, djangorestframework-stubs, pylint, pylint-django (recompiled via uv pip compile).

Safe auto-fixes (640 files)

Mechanical, semantically-inert only: unused-import removal, import sorting, whitespace, List/Dictlist/dict, redundant parens.

Deliberately excluded — caused runtime breakage

  • PEP 604 union rewrites (UP007/UP045): eager-evaluate and raise TypeError at import on shadowed/latent-bad annotations (e.g. a dataclass field named datetime). Re-enable per-file after from __future__ import annotations.
  • __init__.py import sorting (I001): reorders deliberately-ordered imports, breaking circular-dependency management (hit in sync/models/__init__.py).

Verification

  • python manage.py check: clean.
  • All 555 changed importable modules import cleanly.
  • Full suite (manage.py test --keepdb): 956 tests, 1 failure + 2 errors + 7 skipped — all 3 are pre-existing (annotation-data/environment dependent), confirmed identical on clean master. None caused by this change.

Reviewer notes

This is mostly mechanical churn (imports/whitespace). The substantive files to review are ruff.toml, mypy.ini, config/pylint3.rc, scripts/linting/format_code.sh, and requirements.in.

🤖 Generated with Claude Code

…uto-fixes #1586

Tooling:
- ruff.toml: fast lint/format, coexists with pylint. Excludes PEP604 union
  rewrites (UP007/UP045) and __init__ import sorting (I001) - both cause
  runtime breakage via eager-eval annotations / circular-import order.
- mypy.ini + django-stubs/drf-stubs: gradual typing, per-app strictness ratchet.
- Slim config/pylint3.rc to inference E-checks + pylint_django.
- format_code.sh: autopep8 -> ruff check --fix.
- requirements: add ruff, mypy, django-stubs, drf-stubs, pylint, pylint-django.

Apply ruff safe auto-fixes across 640 files: unused imports, import sorting
(excl. __init__), whitespace, list/dict generics, redundant parens.
@davmlaw

davmlaw commented Jun 11, 2026

Copy link
Copy Markdown
Contributor Author

DML review - there are some changes made that remove imports that were wrapped # pylint: disable=unused-import - these
were put there for a reason - need to put them back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant