Skip to content

enum.auto checking correctness per #3434 #3441

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions test-data/unit/check-enum.test
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,17 @@ x = x | C.b
[out]
main:6: error: Incompatible types in assignment (expression has type "int", variable has type "C")

[case testEnumFlagMultiples]
from enum import Flag, auto
class Color(Flag):
RED = auto()
BLUE = auto()
GREEN = auto()
WHITE = RED | BLUE | GREEN
x = Color.RED & Color.BLUE
x = Color.RED or Color.GREEN
x = Color.RED & Color.WHITE

[case testAnonymousEnum]
from enum import Enum
class A:
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/fixtures/bool.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ class bool: pass
class int: pass
class str: pass
class unicode: pass
class ellipsis: pass
1 change: 1 addition & 0 deletions test-data/unit/fixtures/staticmethod.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ class int:
class str: pass
class unicode: pass
class bytes: pass
class ellipsis: pass
5 changes: 5 additions & 0 deletions test-data/unit/lib-stub/enum.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def unique(enumeration: _T) -> _T: pass

class Flag(Enum):
def __or__(self: _T, other: Union[int, _T]) -> _T: pass
def __and__(self: _T, other: Union[int, _T]) -> _T: pass


class IntFlag(int, Flag):
def __and__(self: _T, other: Union[int, _T]) -> _T: pass

class auto(IntFlag):
value = ...
def __init__(self) -> None: pass
2 changes: 1 addition & 1 deletion typeshed
Submodule typeshed updated 416 files