Skip to content

Run strict mypy in pre-commit, clearer errors for missing extras - #25

Merged
lukwam merged 2 commits into
mainfrom
fix/mypy-optional-imports
Oct 26, 2026
Merged

lukwam merged 2 commits into
mainfrom
fix/mypy-optional-imports

Conversation

@lukwam

@lukwam lukwam commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Lands a74fe4f, a commit from Sep 15 that was on a local main but never pushed, rebased onto current main, plus a follow-up commit.

From a74fe4f:

  • mypy in pre-commit. The strict mypy config in pyproject.toml was never run; a local hook now runs it on src, so CI enforces it. The type errors it found are fixed (generic args on Callable/dict, unused ignores, no-untyped-call around google-auth and PyJWT), and ignore_missing_imports is set for firebase_admin, google_auth_oauthlib, django and stripe, which ship no stubs.
  • Clearer errors for missing extras. Importing altissimo.auth.fastapi, .flask, .ninja, .providers.firebase, .providers.google or .providers.jwt without its extra raises ImportError: … Install it with: pip install altissimo-auth[fastapi] instead of a bare ModuleNotFoundError.

Follow-up commit:

  • The mypy hook's entry: mypy only worked with the Poetry venv on PATH, so a plain git commit failed with "Executable mypy not found". It's now poetry run mypy, as in customerio-python.
  • The fallback __version__ was set to 1.0.0 in a74fe4f; it's now 1.1.0, the released version.
  • CHANGELOG entry under Unreleased.

Locally: pre-commit (with mypy) passes both via poetry run and plain pre-commit, and 164 tests pass. Importing altissimo.auth.fastapi with fastapi blocked gives the new message.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RKNZkKLdZpDSx8Nfrignfz

lukwam and others added 2 commits October 26, 2026 13:54
… adapter imports

- Bump the PackageNotFoundError fallback __version__ string to 1.0.0 to
  match the released [project].version (was still 0.1.0).
- Add a local mypy pre-commit hook so the existing strict mypy config is
  actually enforced (it was configured but never run).
- Wrap the optional third-party imports in fastapi/, flask/, ninja/, and
  providers/{firebase,google,jwt}.py in try/except ImportError, re-raising
  with a clear "install with: pip install altissimo-auth[extra]" message
  instead of a raw ModuleNotFoundError.
- Fix the mypy errors this newly-wired hook surfaced: missing generic type
  args (Callable, dict), unused type: ignore comments, untyped-call/
  any-return findings around google-auth's verify_oauth2_token and PyJWT's
  decode(), and added [[tool.mypy.overrides]] ignore_missing_imports for
  firebase_admin, google_auth_oauthlib, django, and stripe, none of which
  ship type stubs.

poetry run pre-commit run --all-files and poetry run pytest both pass
(164 tests).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
- The local mypy pre-commit hook used `entry: mypy`, which only works with
  the Poetry venv on PATH; a plain `git commit` failed with "Executable
  `mypy` not found". Use `poetry run mypy`, as customerio-python does.
- Fallback __version__ is now 1.1.0, matching the released version.
- CHANGELOG entry for these changes under Unreleased.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RKNZkKLdZpDSx8Nfrignfz
@lukwam
lukwam merged commit 3e83b85 into main Oct 26, 2026
5 checks passed
@lukwam
lukwam deleted the fix/mypy-optional-imports branch October 26, 2026 17:58
@lukwam lukwam mentioned this pull request Oct 26, 2026
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