-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Make get_module return typed module #892
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #892 +/- ##
==========================================
+ Coverage 90.31% 90.48% +0.16%
==========================================
Files 70 70
Lines 4917 4937 +20
Branches 1214 1218 +4
==========================================
+ Hits 4441 4467 +26
+ Misses 386 380 -6
Partials 90 90 ☔ View full report in Codecov by Sentry. |
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.
Looking good and this is much nicer than casting & string access! It'd be great to have tests for the corner cases (i.e., passing invalid module name, passing invalid class, ..) and adding tests to fix those codecov warnings.
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.
LGTM, let's get it merged! 🥇
Passing in a string still works and returns either
IotModule
orSmartModule
type when called onIotDevice
orSmartDevice
respectively. When calling onDevice
will returnModule
type.Passing in a module type is then typed to that module, i.e.:
Only thing this doesn't do is check that you can't pass an
IotModule
to aSmartDevice.get_module()
. However there is a runtime check which will return null if the passedModuleType
is not a subclass ofSmartModule
.Many thanks to @cdce8p for helping with this.