Skip to content

Commit 83a8227

Browse files
authored
Remove redundant W503 inline ignores (#233)
1 parent c5223e0 commit 83a8227

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

bugbear.py

+19-19
Original file line numberDiff line numberDiff line change
@@ -303,21 +303,21 @@ def visit_Call(self, node):
303303
with suppress(AttributeError, IndexError):
304304
if (
305305
node.func.id in ("getattr", "hasattr")
306-
and node.args[1].s == "__call__" # noqa: W503
306+
and node.args[1].s == "__call__"
307307
):
308308
self.errors.append(B004(node.lineno, node.col_offset))
309309
if (
310310
node.func.id == "getattr"
311-
and len(node.args) == 2 # noqa: W503
312-
and _is_identifier(node.args[1]) # noqa: W503
313-
and not iskeyword(node.args[1].s) # noqa: W503
311+
and len(node.args) == 2
312+
and _is_identifier(node.args[1])
313+
and not iskeyword(node.args[1].s)
314314
):
315315
self.errors.append(B009(node.lineno, node.col_offset))
316316
elif (
317317
node.func.id == "setattr"
318-
and len(node.args) == 3 # noqa: W503
319-
and _is_identifier(node.args[1]) # noqa: W503
320-
and not iskeyword(node.args[1].s) # noqa: W503
318+
and len(node.args) == 3
319+
and _is_identifier(node.args[1])
320+
and not iskeyword(node.args[1].s)
321321
):
322322
self.errors.append(B010(node.lineno, node.col_offset))
323323

@@ -500,12 +500,12 @@ def check_for_b017(self, node):
500500
item_context = item.context_expr
501501
if (
502502
hasattr(item_context, "func")
503-
and hasattr(item_context.func, "attr") # noqa W503
504-
and item_context.func.attr == "assertRaises" # noqa W503
505-
and len(item_context.args) == 1 # noqa W503
506-
and isinstance(item_context.args[0], ast.Name) # noqa W503
507-
and item_context.args[0].id == "Exception" # noqa W503
508-
and not item.optional_vars # noqa W503
503+
and hasattr(item_context.func, "attr")
504+
and item_context.func.attr == "assertRaises"
505+
and len(item_context.args) == 1
506+
and isinstance(item_context.args[0], ast.Name)
507+
and item_context.args[0].id == "Exception"
508+
and not item.optional_vars
509509
):
510510
self.errors.append(B017(node.lineno, node.col_offset))
511511

@@ -589,7 +589,7 @@ def check_for_b902(self, node):
589589
if "type" in bases:
590590
if (
591591
"classmethod" in decorators.names
592-
or node.name in B902.implicit_classmethods # noqa: W503
592+
or node.name in B902.implicit_classmethods
593593
):
594594
expected_first_args = B902.metacls
595595
kind = "metaclass class"
@@ -599,7 +599,7 @@ def check_for_b902(self, node):
599599
else:
600600
if (
601601
"classmethod" in decorators.names
602-
or node.name in B902.implicit_classmethods # noqa: W503
602+
or node.name in B902.implicit_classmethods
603603
):
604604
expected_first_args = B902.cls
605605
kind = "class"
@@ -644,16 +644,16 @@ def check_for_b903(self, node):
644644
body = node.body
645645
if (
646646
body
647-
and isinstance(body[0], ast.Expr) # noqa: W503
648-
and isinstance(body[0].value, ast.Str) # noqa: W503
647+
and isinstance(body[0], ast.Expr)
648+
and isinstance(body[0].value, ast.Str)
649649
):
650650
# Ignore the docstring
651651
body = body[1:]
652652

653653
if (
654654
len(body) != 1
655-
or not isinstance(body[0], ast.FunctionDef) # noqa: W503
656-
or body[0].name != "__init__" # noqa: W503
655+
or not isinstance(body[0], ast.FunctionDef)
656+
or body[0].name != "__init__"
657657
):
658658
# only classes with *just* an __init__ method are interesting
659659
return

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[flake8]
22
# Keep in sync with .flake8. This copy here is needed for source packages
33
# to be able to pass tests without failing selfclean check.
4-
ignore = E203, E302, E501, E999
4+
ignore = E203, E302, E501, E999, W503
55
max-line-length = 88
66
max-complexity = 12
77
select = B,C,E,F,W,B9

0 commit comments

Comments
 (0)