Skip to content
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

setuptools & distutils: ClassVar mutables (and tuples) #12403

Merged
merged 4 commits into from
Jul 23, 2024

Conversation

Avasam
Copy link
Sponsor Collaborator

@Avasam Avasam commented Jul 22, 2024

Update the type for all class-level dicts, lists and tuples that I found.
Reduces changes in #12400
Reduces bare Any (#9550)

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skimming through this: LGTM

This comment has been minimized.

@Avasam
Copy link
Sponsor Collaborator Author

Avasam commented Jul 22, 2024

mypy_primer looks like a true-positive due to runtime backwards compatibility (that requires a type: ignore)
and I think that the 3.13 stubtest failure is unrelated ? (looks like a Python 3.13 beta 4 update)

@srittau I reset your review since I included a few additional lines right afterward.

@Avasam Avasam requested a review from srittau July 22, 2024 17:52

This comment has been minimized.

@@ -17,7 +19,11 @@ class PlatformInfo:
def cross_dir(self, forcex86: bool = False): ...

class RegistryInfo:
HKEYS: Incomplete
if sys.platform == "win32":
HKEYS: ClassVar[tuple[int, int, int, int]]
Copy link
Contributor

@max-muoto max-muoto Jul 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use Final here? It would effectively interpreted as an immutable ClassVar here.

Copy link
Sponsor Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be made Final. I doubt it's meant to be overridden by subclasses

This comment has been minimized.

Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

setuptools (https://github.com/pypa/setuptools)
+ setuptools/command/__init__.py:6: error: No overload variant of "__setitem__" of "list" matches argument types "str", "Tuple[str, str]"  [call-overload]
+ setuptools/command/__init__.py:6: note: Possible overload variants:
+ setuptools/command/__init__.py:6: note:     def __setitem__(self, SupportsIndex, str, /) -> None
+ setuptools/command/__init__.py:6: note:     def __setitem__(self, slice, Iterable[str], /) -> None

@srittau srittau merged commit 0b1d358 into python:main Jul 23, 2024
66 checks passed
@Avasam Avasam deleted the setuptools-&-distutils-ClassVar-mutables branch July 23, 2024 14:03
max-muoto pushed a commit to max-muoto/typeshed that referenced this pull request Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants