Skip to content

Commit 96206da

Browse files
committed
more
1 parent 66d4ca2 commit 96206da

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class Pet(Enum):
2828
DOG: int
2929

3030
# Mypy will now issue a warning if it detects this situation in type stubs:
31-
# Detected an enum in a type stub with zero members.
31+
# Detected enum "Pet" in a type stub with zero members.
3232
# There is a chance this is due to a recent change in the semantics of enum membership.
3333
# If so, use `member = value` to mark an enum member, instead of `member: type
3434

mypy/checker.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,10 +2598,10 @@ def check_enum(self, defn: ClassDef) -> None:
25982598
if base.is_enum and base.fullname not in ENUM_BASES:
25992599
self.check_final_enum(defn, base)
26002600

2601-
if self.is_stub and not self.is_typeshed_stub and self.tree.fullname != "enum":
2601+
if self.is_stub and self.tree.fullname not in {"enum", "_typeshed"}:
26022602
if not defn.info.enum_members:
26032603
self.fail(
2604-
"Detected an enum in a type stub with zero members. "
2604+
f'Detected enum "{defn.info.fullname}" in a type stub with zero members. '
26052605
"There is a chance this is due to a recent change in the semantics of "
26062606
"enum membership. If so, use `member = value` to mark an enum member, "
26072607
"instead of `member: type`",

test-data/unit/check-enum.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ import lib
17881788

17891789
[file lib.pyi]
17901790
from enum import Enum
1791-
class A(Enum): # E: Detected an enum 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` \
1791+
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` \
17921792
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members
17931793
x: int
17941794
class B(A): # E: Cannot extend enum with existing members: "A"
@@ -1797,7 +1797,7 @@ class B(A): # E: Cannot extend enum with existing members: "A"
17971797
class C(Enum):
17981798
x = 1
17991799
class D(C): # E: Cannot extend enum with existing members: "C" \
1800-
# E: Detected an enum 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` \
1800+
# E: Detected enum "lib.D" 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` \
18011801
# N: See https://typing.readthedocs.io/en/latest/spec/enums.html#defining-members
18021802
x: int # E: Cannot assign to final name "x"
18031803
[builtins fixtures/bool.pyi]

0 commit comments

Comments
 (0)