You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class A(Enum): # E: Detected enum "lib.A" in a type stub with zero members. There is a chance this is due to a recent change in the semantics of enum membership. If so, use `member = value` to mark an enum member, instead of `member: type` \
1950
+
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members
1951
+
x = nonmember(1)
1952
+
1953
+
class B(Enum):
1954
+
@member
1955
+
def x(self) -> None: ...
1956
+
[builtins fixtures/bool.pyi]
1957
+
1941
1958
[case testEnumLiteralValues]
1942
1959
from enum import Enum
1943
1960
@@ -2330,6 +2347,28 @@ def some_a(a: A):
2330
2347
[builtins fixtures/dict.pyi]
2331
2348
2332
2349
2350
+
[case testEnumMemberAndNonMemberSupport]
2351
+
# flags: --python-version 3.11 --warn-unreachable
2352
+
# This was added in 3.11
2353
+
from enum import Enum, member, nonmember
2354
+
2355
+
class A(Enum):
2356
+
x = 1
2357
+
y = member(2)
2358
+
z = nonmember(3)
2359
+
2360
+
def some_a(a: A):
2361
+
if a is not A.x and a is not A.z:
2362
+
reveal_type(a) # N: Revealed type is "Literal[__main__.A.y]"
2363
+
if a is not A.y and a is not A.z:
2364
+
reveal_type(a) # N: Revealed type is "Literal[__main__.A.x]"
2365
+
if a is not A.x:
2366
+
reveal_type(a) # N: Revealed type is "Literal[__main__.A.y]"
2367
+
if a is not A.y:
2368
+
reveal_type(a) # N: Revealed type is "Literal[__main__.A.x]"
0 commit comments