-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fix type problems found by latest mypy #75
Conversation
e789c01
to
63c109e
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.
I see a few regressions to discuss, happy to chat through live.
return functools.partial( | ||
lambda s: origin_type( | ||
lambda s: list( |
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.
I suppose I had thought I would combine the returns in list
and set
, but that wouldn't be readable. Thank-you for making this clearer!
fgpyo/util/metric.py
Outdated
@@ -226,7 +226,7 @@ def parse(cls, fields: List[str]) -> Any: | |||
return inspect.attr_from(cls=cls, kwargs=dict(zip(header, fields)), parsers=parsers) | |||
|
|||
@classmethod | |||
def write(cls, path: Path, *values: MetricType) -> None: | |||
def write(cls, path: Path, *values: "Metric") -> None: |
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.
Why loose this type hint? It only writes metrics of this type, so should it not be MetricType
?
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.
Add the bound on MetricType
to have Metric
@@ -9,20 +10,19 @@ | |||
from typing import TypeVar | |||
from typing import Union | |||
|
|||
try: | |||
# `get_origin_type` is a method that gets the outer type (ex list in a List[str]) | |||
# `get_arg_types` is a method that gets the inner type (ex str in a List[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.
thank-you for adding this explanation, I forget every time.
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 based on in-person review
Closes #73 * Move to current latest version of pytest to avoid deprecation warning * Move to current latest version of mypy * Correct multiple problems with type and import flagged by newer mypy
63c109e
to
62f2583
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #75 +/- ##
==========================================
- Coverage 93.01% 92.88% -0.14%
==========================================
Files 30 30
Lines 3119 3118 -1
Branches 579 581 +2
==========================================
- Hits 2901 2896 -5
- Misses 145 148 +3
- Partials 73 74 +1 ☔ View full report in Codecov by Sentry. |
Closes Newer versions of mypy reject multiple lines of fgpyo #73