-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
stubtest: flag redundant @disjoint_base decorators #19715
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1407,14 +1407,9 @@ def spam(x=Flags4(0)): pass | |
| stub=""" | ||
| import sys | ||
| from typing import Final, Literal | ||
| from typing_extensions import disjoint_base | ||
| if sys.version_info >= (3, 12): | ||
| class BytesEnum(bytes, enum.Enum): | ||
| a = b'foo' | ||
| else: | ||
| @disjoint_base | ||
| class BytesEnum(bytes, enum.Enum): | ||
| a = b'foo' | ||
| class BytesEnum(bytes, enum.Enum): | ||
| a = b'foo' | ||
|
Comment on lines
-1410
to
+1411
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. one way to keep the test as it was before would be to just have it be an "abstract enum" that doesn't have any members
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I complicated this test in a previous PR for disjoint_base, so I don't feel bad about going back to the previous less complicated version. |
||
|
|
||
| FOO: Literal[BytesEnum.a] | ||
| BAR: Final = BytesEnum.a | ||
| BAZ: BytesEnum | ||
|
|
@@ -1698,6 +1693,53 @@ def __next__(self) -> object: ... | |
| """, | ||
| error=None, | ||
| ) | ||
| yield Case( | ||
| runtime=""" | ||
| class IsDisjointBaseBecauseItHasSlots: | ||
| __slots__ = ("a",) | ||
| a: int | ||
| """, | ||
| stub=""" | ||
| from typing_extensions import disjoint_base | ||
|
|
||
| @disjoint_base | ||
| class IsDisjointBaseBecauseItHasSlots: | ||
| a: int | ||
| """, | ||
| error="test_module.IsDisjointBaseBecauseItHasSlots", | ||
| ) | ||
| yield Case( | ||
| runtime=""" | ||
| class IsFinalSoDisjointBaseIsRedundant: ... | ||
| """, | ||
| stub=""" | ||
| from typing_extensions import disjoint_base, final | ||
|
|
||
| @final | ||
| @disjoint_base | ||
| class IsFinalSoDisjointBaseIsRedundant: ... | ||
| """, | ||
| error="test_module.IsFinalSoDisjointBaseIsRedundant", | ||
| ) | ||
| yield Case( | ||
| runtime=""" | ||
| import enum | ||
|
|
||
| class IsEnumSoDisjointBaseIsRedundant(enum.Enum): | ||
| A = 1 | ||
| B = 2 | ||
| """, | ||
| stub=""" | ||
| from typing_extensions import disjoint_base | ||
| import enum | ||
|
|
||
| @disjoint_base | ||
| class IsEnumSoDisjointBaseIsRedundant(enum.Enum): | ||
| A = 1 | ||
| B = 2 | ||
| """, | ||
| error="test_module.IsEnumSoDisjointBaseIsRedundant", | ||
JelleZijlstra marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| @collect_cases | ||
| def test_has_runtime_final_decorator(self) -> Iterator[Case]: | ||
|
|
||
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.
these feel like linter issues more than correctness issues (so sort-of outside of stubtest's normal purview?), but it's obviously very easy to check for them here, so I think it makes sense
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.
Yeah we could also add these checks to flake8-pyi/ruff/whatever.