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
|
sentrivana
left a comment
There was a problem hiding this comment.
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
|
@sentrivana, yeah we are; I found ca. 100 usages after these changes. |
Improve
get_integrationtyping to make it clear that we return anOptional[Integration]. Further, add overloads to specify that when called with some integration typeI(i.e.Iis a subclass ofIntegration), thenget_integrationguarantees a return value ofOptional[I].These changes should enhance type safety by explicitly guaranteeing the existing behavior of
get_integration.