-
Notifications
You must be signed in to change notification settings - Fork 175
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
Mypy cleanup #1562
Mypy cleanup #1562
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop-1.9 #1562 +/- ##
===============================================
- Coverage 85.62% 85.57% -0.06%
===============================================
Files 140 140
Lines 15299 15360 +61
===============================================
+ Hits 13100 13144 +44
- Misses 2199 2216 +17 ☔ 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.
Some inconsistencies in usage of Union
or Optional
vs |
syntax, as well as Mapping
vs dict
even considering recommended input/return annotation conventions
if "time" in [f.name for f in match_fields]: | ||
return self.get_duplicates_with_time(match_fields, expressions) | ||
|
||
group_expressions = tuple(f.alchemy_expression for f in match_fields) | ||
group_expressions = tuple(type_cast(PgField, f).alchemy_expression for f in match_fields) |
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.
What's the benefit of casting here rather than providing a more specific type hint?
@@ -845,7 +838,7 @@ def clone(self, orig: Dataset, for_save=False, lookup_locations=True) -> Dataset | |||
else: | |||
uris = [] | |||
if len(uris) == 1: | |||
kwargs = {"uri": uris[0]} | |||
kwargs: dict[str, Any] = {"uri": uris[0]} |
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.
Don't we know that uris[0]
will be a str
?
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.
We do, but eg. kwargs["uris"]
is a list[str]
so the variable typehint has to be broader. Could probably be tighter than Any
though.
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 whole file should probably be deleted
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.
Yeah, I was wondering about that - definitely after we bring in eo3
as a dependency. I'll have a look at internal usages and see if we can delete it now.
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 file should also probably be deleted
Yeah I don't pretend to have addressed all inconsistencies. |
Reason for this pull request
Get develop-1.9 branch pass mypy checks and add a github action to preserve compliance going forwards
Proposed changes
Add missing typehints; fix broken typehints; refactor some code to make more amenable to static analysis; add casts, asserts and other hints; and where all else fails add an explicit ignore directive.
Some obscure old bugs have been shaken out and fixed,
I'm not overly concerned about the codecov report - codecov doesn't cope well with this sort of extensive but superficial PR.
docs/about/whats_new.rst
for all changes