-
-
Notifications
You must be signed in to change notification settings - Fork 643
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
upgrade mypy to v1.10.1 #21158
upgrade mypy to v1.10.1 #21158
Conversation
I know reports indicate this doesn't fully fix #18519, but I don't think there is any reason not to do this upgrade. Anything todo before un-drafting? |
Still need to cleanup unused type comments as per this build failure: https://github.com/pantsbuild/pants/actions/runs/9894141143/job/27331097301?pr=21158 |
And still not understanding why inclusion of
But I haven't tracked whether types-setuptools actually has the requisite type stubs. |
Gave up on trying to solve the |
Merged in |
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.
Thanks for doing this!
@@ -454,7 +454,7 @@ async def create_tool_runner( | |||
|
|||
append_only_caches = { | |||
**merged_extras.append_only_caches, | |||
**(request.named_caches or {}), | |||
**(request.named_caches or {}), # type: ignore[dict-item] |
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.
It looks like it's this or
construct that's causing the issues, likely because the {}
becomes dict[Never, Never]
and that apparently doesn't satisfy SupportsKeysAndGetItem[K, V]
with the specific K
and V
types.
def direct_splat_frozen_only(fd: FrozenDict[str, int]) -> dict[str, int]:
return {**fd} # okay
def direct_splat_dict_too(fd: FrozenDict[str, int] | dict[str, int]) -> dict[str, int]:
return {**fd} # okay
def or_splat_explicit(fd: FrozenDict[str, int]) -> dict[str, int]:
empty: dict[str, int] = {}
return {**(fd or empty)} # okay
def or_splat_implicit(fd: None | FrozenDict[str, int]) -> dict[str, int]:
return {**(fd or {})} # error: Unpacked dict entry 0 has incompatible type "FrozenDict[str, int] | dict[Never, Never]"; expected "SupportsKeysAndGetItem[str, int]" [dict-item]
https://mypy-play.net/?mypy=latest&python=3.12&gist=661f39bc47fc9b1b4f8a80fe0814d1c1
I filed python/mypy#17790
Happy to go with what you've got for 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.
Interesting. Yeah, let's ignore it for now. If and when it gets fixed upstream, we should get a "unused type ignore" error once the ignore is no longer necessary.
Upgrade MyPy to v1.10.1 for Pants' own source code.
Overview of issues found:
# type: ignore
comments were removed due to improvements in MyPy.dataclasses.replace
where the code was using the wrong type for a replaced field (especially egregious since some cases passed in a mutable list where an immutable value was expected to be stored in the (frozen) dataclass).FrozenDict
implements theSupportsKeysAndGetItem
protocol (for whatever reasons) and so I added ignores ofdict-item
in certain places.strawberry-graphql
which is used by repo-internal pluginpants-plugins/pants_explorer/server
to work around an ICE inmypy
. I also had to add some# type: ignore
comments to that module. I have not testedpants_explorer
since I did not find a README about how to use it for Pants development.