Skip to content

Commit d8786cf

Browse files
committed
Merge pull request #313 from hongqn/e721-noqa
allow use # noqa to disable E721 warning
2 parents 6086f61 + 69a3a3d commit d8786cf

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/intro.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ This is the current list of error and warning codes:
361361
+----------+----------------------------------------------------------------------+
362362
| E714 | test for object identity should be 'is not' |
363363
+----------+----------------------------------------------------------------------+
364-
| E721 | do not compare types, use 'isinstance()' |
364+
| E721 (^) | do not compare types, use 'isinstance()' |
365365
+----------+----------------------------------------------------------------------+
366366
| E731 | do not assign a lambda expression, use a def |
367367
+----------+----------------------------------------------------------------------+

pep8.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,7 +1053,7 @@ def comparison_negative(logical_line):
10531053
yield pos, "E714 test for object identity should be 'is not'"
10541054

10551055

1056-
def comparison_type(logical_line):
1056+
def comparison_type(logical_line, noqa):
10571057
r"""Object type comparisons should always use isinstance().
10581058
10591059
Do not compare types directly.
@@ -1069,7 +1069,7 @@ def comparison_type(logical_line):
10691069
Okay: if type(a1) is type(b1):
10701070
"""
10711071
match = COMPARE_TYPE_REGEX.search(logical_line)
1072-
if match:
1072+
if match and not noqa:
10731073
inst = match.group(1)
10741074
if inst and isidentifier(inst) and inst not in SINGLETONS:
10751075
return # Allow comparison for types which are not obvious

0 commit comments

Comments
 (0)