-
Notifications
You must be signed in to change notification settings - Fork 550
ref(client): Improve get_integration
typing
#3550
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
ref(client): Improve get_integration
typing
#3550
Conversation
Codecov ReportAttention: Patch coverage is
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3550 +/- ##
==========================================
- Coverage 84.51% 84.29% -0.22%
==========================================
Files 133 133
Lines 13855 13885 +30
Branches 2930 2929 -1
==========================================
- Hits 11709 11705 -4
- Misses 1421 1440 +19
- Partials 725 740 +15
|
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.
Nice, LGTM as is, but mypy is complaining so this will probably need additional changes, would prefer to review once it's ready :)
@sentrivana yep still working on fixing mypy, will mark as draft until this is ready to be reviewed. I think the cleanest solution will be to replace We can still use |
b3678cb
to
d0fa5d5
Compare
The |
Improve `get_integration` typing to make it clear that we return an `Optional[Integration]`. Further, add overloads to specify that when called with some integration type `I` (i.e. `I` is a subclass of `Integration`), then `get_integration` guarantees a return value of `Optional[I]`. These changes should enhance type safety by explicitly guaranteeing the existing behavior of `get_integration`.
d0fa5d5
to
bad136f
Compare
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.
Are we still using ensure_integration_enabled
anywhere after this? If not, we can remove it.
@sentrivana, yeah we are; I found ca. 100 usages after these changes. |
Improve
get_integration
typing to make it clear that we return anOptional[Integration]
. Further, add overloads to specify that when called with some integration typeI
(i.e.I
is a subclass ofIntegration
), thenget_integration
guarantees a return value ofOptional[I]
.These changes should enhance type safety by explicitly guaranteeing the existing behavior of
get_integration
.