Add type annotations to Credential model methods#2977
Merged
jonathangreen merged 1 commit intomainfrom Jan 11, 2026
Merged
Conversation
- Add comprehensive type hints to lookup, lookup_by_token, lookup_and_expire_temporary_token, temporary_token_create, persistent_token_create, and __repr__ methods - Enable strict mypy checking for credential module by removing it from the exclusion list in pyproject.toml - Make token and token_type parameters non-nullable where semantically appropriate (looking up by None values is a bug) - Fix classmethod using 'self' instead of 'cls' in persistent_token_create - Fix incorrect indentation in lookup_by_patron return statement - Add test assertions for type narrowing on nullable fields
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2977 +/- ##
=======================================
Coverage 92.81% 92.81%
=======================================
Files 454 454
Lines 42942 42942
Branches 5999 5999
=======================================
Hits 39857 39857
Misses 2016 2016
Partials 1069 1069 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add comprehensive type annotations to the
Credentialmodel methods and enable strict mypy checking for the module.Key changes:
lookup,lookup_by_token,lookup_and_expire_temporary_token,temporary_token_create,persistent_token_create, and__repr__methodstokenandtoken_typeparameters non-nullable where semantically appropriate (looking up byNonevalues is logically a bug)selfinstead ofclsinpersistent_token_createlookup_by_patronreturn statementMotivation and Context
This change improves type safety in the Credential model by:
How Has This Been Tested?
Checklist