-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update classifier code for mypy #2122
Conversation
@@ -316,139 +311,6 @@ def and_up(cls, young, keyword): | |||
return old | |||
|
|||
|
|||
class GradeLevelClassifier(Classifier): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class was duplicated, and this copy wasn't being used, so I deleted it.
# TODO: Eventually I'd like to refactor this, so we don't have to use __getattr__ | ||
# here, and can just import the GenreData objects directly. | ||
def __getattr__(name: str) -> GenreData: | ||
return genres_by_variable_name[name] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the core of the change in this PR.
@@ -821,710 +694,3 @@ def __new__(cls, value): | |||
def scrub_identifier(cls, identifier): | |||
if not identifier: | |||
return identifier | |||
|
|||
|
|||
class AgeOrGradeClassifier(Classifier): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These classes were just moved out to age.py
, to break an import cycle.
subject2 = data.transaction.subject(type="type2", identifier="subject2") | ||
subject2.target_age = NumericRange(6, 8, "[)") | ||
subject2.weight_as_indicator_of_target_age = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weight_as_indicator_of_target_age
isn't a property that is defined, and wasn't necessary to set for the test, so I just removed these properties.
246b379
to
fe56463
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2122 +/- ##
==========================================
+ Coverage 90.73% 90.81% +0.07%
==========================================
Files 351 352 +1
Lines 40904 40850 -54
Branches 8874 8850 -24
==========================================
- Hits 37115 37098 -17
+ Misses 2481 2444 -37
Partials 1308 1308 ☔ View full report in Codecov by Sentry. |
Codecov is complaining, but any code that isn't covered by this, wasn't covered before, so I think this is fine for review without adding more coverage. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaning up! 🧹🎸
Nice to get most of that stuff out of the __init__
and to get rid of those *
imports!
Description
from palace.manager.core.classifier import *
__getattr__
method toclassifier/__init__.py
to let mypy know to expect dynamic importsGradeLevelClassifier
classMotivation and Context
check_untyped_defs
mypy option.How Has This Been Tested?
Checklist