Skip to content

Commit 861c9a4

Browse files
committed
Add a failing test for a custom types module case
Any `types.*Type*` matches incorrectly as a `type(...)` comparison; the regex `COMPARE_TYPE_REGEX` seems a bit too complicated for what should be a simple comparison case. Ref: https://github.com/PyCQA/pycodestyle/blob/main/pycodestyle.py#L147-L148 This reproduces the case in #830
1 parent 9777ac5 commit 861c9a4

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

testsuite/E72.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,8 @@ def func_histype(a, b, c):
8080
pass
8181
except Exception:
8282
pass
83+
#: Okay
84+
from . import custom_types as types
85+
86+
red = types.ColorTypeRED
87+
red is types.ColorType.RED

testsuite/custom_types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import enum
2+
3+
4+
class ColorType(enum.Enum):
5+
RED = 1
6+
GREEN = 2
7+
BLUE = 3

0 commit comments

Comments
 (0)