-
Notifications
You must be signed in to change notification settings - Fork 10
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
Better inheritance and more #264
Conversation
Also abstract _get_path() for some Effects
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## dev_master #264 +/- ##
==============================================
+ Coverage 80.05% 80.20% +0.14%
==============================================
Files 143 143
Lines 14777 14779 +2
==============================================
+ Hits 11830 11853 +23
+ Misses 2947 2926 -21
☔ View full report in Codecov by Sentry. |
From the coverage report, I noticed that If anyone feels confident to write more meaningful tests for this class, by all means please do so! |
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 makes everything a bit better and more generic. So lets get this merged.
Filtercurve impression: ➰ ➰ ➰
About your future plans: sounds good. I'm not sure why the elements of meta
aren't just attributes of the classes. Maybe the Effect
classes could even be dataclasses. But if it ain't broken, we shouldn't fix it. And now it was kinda broken, and you took it a step in the right direction.
This solves the "grandfather super()" issue in the
FilterWheel
subclasses by introducing aFilterWheelBase
base class, to separate code that applies toFilterWheel
but not to subclasses (which isn't a lot anyway).Inspired by the main conflict (different required keys) that led to this issue in the first place, I made some changes to how
required_keys
is handled: I made it a class attribute, and callcheck_keys
afterwards. This is in preparation for a change I started thinking about some time ago: Move thecheck_keys
call up in the inheritance, either as part ofEffect
or a new class in between. Since subclass attributes take priority above parent class attributes, that should work fine and remove thecheck_keys
call from the subclasses. For now, I only changed things in the classes affected here anyway, in a backwards-compatible way, to keep this PR limited.Additionally, I had noticed earlier that several
Effect
subclasses define a very similardisplay_name
property (overriding that property fromEffect
). The only difference was the key used to get the name from currsys, usually some"current_xy"
. So for those classes, I introduced another class attribute_current_str
, which holds that key (string), hardcoded. The (previously existing) propertyEffect.display_name
now checks if that attribute exists and falls back to the previous behavior if that's not the case. So, all behaviors should stay the same, but with less code duplication.Finally, in the same move, I also abstracted
._get_path()
toEffect
, because the very same line existed in at least 4 unrelated subclasses. Again, if the subclass in question does not have the required keys, nothing happens.Opinions and comments on all of this are of course welcome 😄