Skip to content

build(python): upgrade mypy to 2.4.1 and make it runnable - #39

Merged
zarmstrong merged 2 commits into
masterfrom
build/mypy-upgrade
Nov 23, 2026
Merged

zarmstrong merged 2 commits into
masterfrom
build/mypy-upgrade

Conversation

@zarmstrong

@zarmstrong zarmstrong commented Nov 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

mypy was pinned to 0.961 in both the Poetry dev group (^0.961, which Poetry reads as >=0.961,<0.962) and the pre-commit hook (mirrors-mypy rev: v0.961). The automated dependency update never proposed a bump because of those pins.

It also never ran successfully. The empty root __init__.py made mypy treat the checkout as an autoshift package, so every module was seen twice (autoshift.query and query) and mypy stopped with "Source file found twice under different module names". In a checkout folder whose name has a hyphen, it failed earlier still. Nothing imports autoshift.*, so the file is removed.

Changes:

  • Remove the root __init__.py.
  • Add [tool.mypy] to pyproject.toml (files, python_version = "3.11", ignore_missing_imports), so a plain mypy command behaves the same locally, in pre-commit, and in CI.
  • Dev group: mypy = "^2.4.1", add types-requests. Re-locked. The lock also moves urllib3 1.26.9 → 2.8.0, which types-requests requires; Docker and CI already get urllib3 2.x from requirements.txt.
  • pre-commit: mirrors-mypy v2.4.1 with types-requests and beautifulsoup4 as additional_dependencies; the arguments now come from the config.
  • Tests workflow: new mypy job.
  • Fix the existing type errors without changing runtime behaviour:
    • declare the Key attributes on the class
    • replace the parse_shift_orcicorn.first_parse function attribute with a module-level flag
    • Optional[str] defaults for ShiftClient
    • annotate migrationFunctions
    • Database.__exit__ returns None (same behaviour as False)
    • cast(str, …) on single-valued bs4 attributes
  • AGENTS.md: the mypy command is now just mypy.

Validation

  • mypy (2.4.1, runtime dependencies + types-requests installed): Success: no issues found in 5 source files
  • pre-commit run mypy --all-files: Passed
  • python -m unittest discover -s tests: 24 tests OK
  • python auto.py --help: OK
  • flake8 *.py: no new warnings (103 vs 105 on master)
  • Merged current master (fix(deps): bump runtime, dev, and CI dependencies #37); dev-group conflict resolved and re-locked. The new mypy job uses checkout@v7 / setup-python@v7, matching the unittest job.
  • Codex review (2 rounds): no actionable findings.
  • CI on the latest commit: mypy, unittest (Python 3.11) and unittest (Python 3.14) pass.

🤖 Generated with Claude Code

xxxxxxxxxxxxx and others added 2 commits November 23, 2026 11:48
mypy was pinned to 0.961 in both the Poetry dev group and the
pre-commit hook, and never actually ran: the empty root __init__.py
made mypy see each module under two names ("autoshift.query" and
"query"). Remove it, move mypy settings into [tool.mypy], bump to
2.4.1 with types-requests, fix the existing type errors without
changing runtime behaviour, and add a mypy job to the Tests workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the dev-group conflict with the combined dependency bump (#37),
re-lock, and use actions/checkout@v7 and setup-python@v7 in the new
mypy job to match the unittest job.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zarmstrong
zarmstrong marked this pull request as ready for review November 23, 2026 18:52
@zarmstrong
zarmstrong merged commit d6898b5 into master Nov 23, 2026
3 checks passed
@zarmstrong
zarmstrong deleted the build/mypy-upgrade branch November 23, 2026 18:55
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.

2 participants