summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Savchenko <asfaltboy@gmail.com>2021-12-12 08:28:59 +0000
committerPavel Savchenko <asfaltboy@gmail.com>2021-12-12 08:29:12 +0000
commit861c9a40fda1bf5094dc4229d0b00ec7e9ac8765 (patch)
tree8462e904ec15be1e8cb2e59cf31974e54921a70c
parent9777ac5a8ea1ae14e70bfb27063e2e7c0daa06e3 (diff)
downloadpep8-861c9a40fda1bf5094dc4229d0b00ec7e9ac8765.tar.gz
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
-rw-r--r--testsuite/E72.py5
-rw-r--r--testsuite/custom_types.py7
2 files changed, 12 insertions, 0 deletions
diff --git a/testsuite/E72.py b/testsuite/E72.py
index a60d892..e789d82 100644
--- a/testsuite/E72.py
+++ b/testsuite/E72.py
@@ -80,3 +80,8 @@ try:
pass
except Exception:
pass
+#: Okay
+from . import custom_types as types
+
+red = types.ColorTypeRED
+red is types.ColorType.RED
diff --git a/testsuite/custom_types.py b/testsuite/custom_types.py
new file mode 100644
index 0000000..43daf02
--- /dev/null
+++ b/testsuite/custom_types.py
@@ -0,0 +1,7 @@
+import enum
+
+
+class ColorType(enum.Enum):
+ RED = 1
+ GREEN = 2
+ BLUE = 3