-
-
Notifications
You must be signed in to change notification settings - Fork 139
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 0.981 compatibility #336
Comments
This is an actual ambiguity/error as
I think there might be two issues, something about using HashableT (replacing it with Any solves many of those errors - not sure what's going on there) and probably a mypy bug as edit: opened python/mypy#13750
Could be a mypy bug with how it handles HashableT: the typevar is used a second time in the declaration of get_dummies (so the two instances have to have the same type) but the second time it is not used because columns is not passed.
It seems that I will try to create minimal examples later and report them at mypy. |
@hauntsaninja it might be great to add pandas-stubs to mypy-primer. Pandas-stubs has many annotations and some of them might also be dubious - perfect test case for mypy-primer :) |
Thanks, added! |
Mypy 0.981 adds support for unpacking kwargs python/mypy#13471 from typing import TypedDict
from typing_extensions import Unpack
class Style(TypedDict, total=False):
margin: int
sticky: bool
def add_button(label: str, **kwds: Unpack[Style]) -> None:
... That could make many overloads much smaller and easier to understand as we can put all the non-overload-related keywords in a TypedDict! |
Created python/mypy#13760 It seems that 0.971 did type narrowing on unions, but 0.981 does it inconsistently. |
With respect to If we want a type to correspond to what could be a column name or index name, we could do something like: ValidName= Union[str, complex, Timestamp, Timedelta, tuple, None, OTHER_TYPES]
ValidNameT = TypeVar("ValidNameT", bound=ValidName) where This might (but I'm not sure) clean up these mypy issues. |
I would first wait for the next mypy release (or check mypy main) to know which errors are actual errors and which aren't. I think pandas-stubs/core/series.pyi:440 is an error/ambiguity. Since type checkers pick the first matching overload, we could live with this ambiguity. |
With mypy 0.982, we are now down to only three errors :) We need to fix this (or ignore it):
Union-simplifications (wait for mypy 0.983?):
|
I think we have to just add a
So they claimed to have fixed the bug here: python/mypy#13781 But I looked at the source for tag for 0.982, and it doesn't include that fix, so let's wait for that. |
If we had a good solution for optional CI runs that are allowed to fail without screaming in red that they failed, it might be nice to add a run with mypy nightly. This would allow us to more quickly correct errors that newer versions of mypy will detect and if mypy has unexpected behaviors, we can report them before a new version is released. |
mypy 0.981 released on 9/26/22. If you do a manual re-run of a job, it picks that up, and we get some failures. Could be mypy bugs, or settings, or errors we need to fix.
Might be able to remove the python 3.10.6 restriction, since I think 0.981 is supposed to fix the issue of using 3.10.7 or later.
The text was updated successfully, but these errors were encountered: