Skip to content

Commit

Permalink
Update classifier code for mypy (#2122)
Browse files Browse the repository at this point in the history
- Remove all star imports for classifier code from palace.manager.core.classifier import *
- Add a __getattr__ method to classifier/__init__.py to let mypy know to expect dynamic imports
- Move around some of the classifier code to break import cycle
- Remove duplicated GradeLevelClassifier class
  • Loading branch information
jonathangreen authored Oct 22, 2024
1 parent de50019 commit 498ebb6
Show file tree
Hide file tree
Showing 29 changed files with 1,463 additions and 1,571 deletions.
12 changes: 0 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ profile = "black"
# to silence the noise in the mypy output for now, so its easier to see when
# there are errors in the output.
disable_error_code = "annotation-unchecked"
exclude = [
'core/classifier',
]
explicit_package_bases = true
files = ["alembic", "src/palace", "tests"]
mypy_path = ["alembic", "src"]
Expand Down Expand Up @@ -160,15 +157,6 @@ strict_equality = true
warn_return_any = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
# This override silences errors for modules in our own codebase that we import
# from other covered modules. Ideally we will be able to remove this override
# eventually, once we have type hints for all of our own code.
follow_imports = "silent"
module = [
"palace.manager.core.classifier.*",
]

[[tool.mypy.overrides]]
# This override silences errors for modules we import that don't currently
# have type hints, or type stubs that cover them. We should go through this
Expand Down
8 changes: 2 additions & 6 deletions src/palace/manager/api/admin/controller/work_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@
LIBRARY_NOT_FOUND,
REMOTE_INTEGRATION_FAILED,
)
from palace.manager.core.classifier import (
NO_NUMBER,
NO_VALUE,
SimplifiedGenreClassifier,
genres,
)
from palace.manager.core.classifier import NO_NUMBER, NO_VALUE, genres
from palace.manager.core.classifier.simplified import SimplifiedGenreClassifier
from palace.manager.feed.acquisition import OPDSAcquisitionFeed
from palace.manager.feed.annotator.admin import AdminAnnotator
from palace.manager.sqlalchemy.model.classification import (
Expand Down
Loading

0 comments on commit 498ebb6

Please sign in to comment.