Skip to content

Conversation

@JelleZijlstra
Copy link
Member

No description provided.

@github-actions

This comment has been minimized.

@AlexWaygood
Copy link
Member

I almost wonder if it's worth adding a variant is_disjoint_base_if, which you can pass a condition to providing the type checker can statically infer its truthiness. E.g.

@disjoint_base_if(sys.version_info< (3, 11))classFoo(tuple): ...

Maybe that would just be overcomplicating the proposal, though

@JelleZijlstra
Copy link
MemberAuthor

I've been thinking about a more general version, where we add a do-nothing identity decorator so you can write @(disjoint_base if sys.version_info >= (3, 12) else identity). Maybe not worth it though.

Pyright seems very unhappy here presumably because I added one too many sys.version_info branches, will try to figure out which one pushed it over the edge.

Some of the remaining stubtest errors are false positives, fixing in python/mypy#19701

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

I think for pure-Python classes that are disjoint bases because they have __slots__, we should generally just add the __slots__ rather than adding the @disjoint_base decorator? That will help type checkers in other ways too (#8832). I highlighted a few here, but I think there are probably some more

@JelleZijlstra
Copy link
MemberAuthor

I think for pure-Python classes that are disjoint bases because they have slots, we should generally just add the slots rather than adding the @disjoint_base decorator? That will help type checkers in other ways too (#8832). I highlighted a few here, but I think there are probably some more

Yes, I agree, but I'd rather not have to look at all of these classes manually.

@AlexWaygood
Copy link
Member

I've been thinking about a more general version, where we add a do-nothing identity decorator so you can write @(disjoint_base if sys.version_info >= (3, 12) else identity). Maybe not worth it though.

yes, that's quite appealing, actually, from my perspective as a typeshed maintainer -- it would also be useful for deprecations, since we have an increasing number of sys.version_info branches where the only difference between the branches is that a function is marked with @deprecated in one branch but not in the other.

Although that's actually quite convenient for us over at ty, because the deprecation notice is often also reflected in the docstring, and docstring-adder will add the version-specific docstrings to the two branches.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Copy link
Member

@AlexWaygoodAlexWaygood left a comment

Choose a reason for hiding this comment

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

LGTM if you fix the TarInfo CI failure!

@JelleZijlstra
Copy link
MemberAuthor

I think I need #14626 for CI to go green. I'll also wait for my mypy PR to be merged so I can pin stubtest to a commit from mypy master rather than a random one from my fork.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@JelleZijlstra
Copy link
MemberAuthor

Had to make some more tweaks to accommodate recent stubtest changes, but it's looking green now. I ignored one issue with _random.Random in 3.10 only that seemed annoying, we can deal with that later.

@github-actions
Copy link
Contributor

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

ibis (https://github.com/ibis-project/ibis) - ...typeshed_to_test/stdlib/builtins.pyi:115: note: "Any" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:117: note: "Any" defined here- ...typeshed_to_test/stdlib/builtins.pyi:115: note: "__init__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:117: note: "__init__" of "object" defined here strawberry (https://github.com/strawberry-graphql/strawberry) - ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here- ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here prefect (https://github.com/PrefectHQ/prefect) - ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here- ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here- ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here- ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here- ...typeshed_to_test/stdlib/builtins.pyi:137: note: "__init_subclass__" of "object" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:139: note: "__init_subclass__" of "object" defined here zulip (https://github.com/zulip/zulip) - ...typeshed_to_test/stdlib/builtins.pyi:115: note: "SubTest" defined here+ ...typeshed_to_test/stdlib/builtins.pyi:117: note: "SubTest" defined here discord.py (https://github.com/Rapptz/discord.py) - ...typeshed_to_test/stdlib/typing.pyi:1042: note: "update" of "TypedDict" defined here+ ...typeshed_to_test/stdlib/typing.pyi:1043: note: "update" of "TypedDict" defined here- discord/ext/commands/hybrid.py:834: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command" [misc]+ discord/ext/commands/hybrid.py:834: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name" [misc]- discord/ext/commands/hybrid.py:858: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command" [misc]+ discord/ext/commands/hybrid.py:858: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name" [misc]- discord/ext/commands/hybrid.py:883: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command" [misc]+ discord/ext/commands/hybrid.py:883: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name" [misc]- discord/ext/commands/hybrid.py:935: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command" [misc]+ discord/ext/commands/hybrid.py:935: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name" [misc]- discord/ext/commands/bot.py:290: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command" [misc]+ discord/ext/commands/bot.py:290: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name" [misc]- discord/ext/commands/bot.py:314: error: Overlap between argument names and ** TypedDict items: "name", "with_app_command" [misc]+ discord/ext/commands/bot.py:314: error: Overlap between argument names and ** TypedDict items: "with_app_command", "name" [misc]

@JelleZijlstraJelleZijlstra merged commit e8ba06f into python:mainAug 24, 2025
63 checks passed
@tungol
Copy link
Contributor

It's great to see all those allowlist entries go away

@JelleZijlstraJelleZijlstra deleted the disjointbase branch August 24, 2025 23:14
@cdce8pcdce8p mentioned this pull request Aug 31, 2025
Sign up for freeto 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

@JelleZijlstra@AlexWaygood@tungol