Add type annotations to Admin and AdminRole models#2976
Merged
jonathangreen merged 2 commits intomainfrom Jan 11, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2976 +/- ##
==========================================
- Coverage 92.82% 92.81% -0.01%
==========================================
Files 454 454
Lines 42942 42947 +5
Branches 5998 6000 +2
==========================================
+ Hits 39860 39861 +1
- Misses 2014 2016 +2
- Partials 1068 1070 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Add comprehensive type hints to all methods in the Admin and AdminRole classes, enabling mypy type checking for this module. Changes: - Add type annotations to all Admin class methods - Add type annotations to all AdminRole class methods - Add type annotations to nested lookup_hook functions - Handle None library parameter in is_library_manager and is_librarian - Add necessary imports (TYPE_CHECKING, Any, Query, Collection) - Remove module from mypy exclusion list
8cc2a25 to
521d2c2
Compare
Member
Author
|
Codecov is complaining about patch coverage, but the coverage gaps were pre-existing, so I think we can ignore it on this PR. |
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 hints to all methods in the
AdminandAdminRoleclasses insrc/palace/manager/sqlalchemy/model/admin.py, enabling mypy type checking for this module.Additional changes:
Nonehandling foris_library_managerandis_librarianmethods to fix a type error inindividual_admin_settings.pywhererole.library(which can beNonefor sitewide roles) was passed to these methodsTYPE_CHECKING,Any,Query, andCollection(under TYPE_CHECKING to avoid circular imports)# type: ignorecomment to@validatesdecorator (known SQLAlchemy typing issue)palace.manager.sqlalchemy.model.adminfrom mypy exclusion list inpyproject.tomlMotivation and Context
This change improves type safety and code quality by enabling mypy static type checking for the Admin and AdminRole models. The
Nonehandling fix ensures the code correctly handles sitewide roles wherelibraryisNone.How Has This Been Tested?
mypypasses with no errorstests/manager/sqlalchemy/model/test_admin.pypass (9 tests)Checklist