From 35debd8c6aadd4facfaadae34e38c8ca8af2e747 Mon Sep 17 00:00:00 2001 From: jpy-git Date: Thu, 17 Mar 2022 23:20:09 +0000 Subject: [PATCH] Remove redundant W503 inline ignores --- bugbear.py | 38 +++++++++++++++++++------------------- setup.cfg | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/bugbear.py b/bugbear.py index 5e7ea93..61e328e 100644 --- a/bugbear.py +++ b/bugbear.py @@ -303,21 +303,21 @@ def visit_Call(self, node): with suppress(AttributeError, IndexError): if ( node.func.id in ("getattr", "hasattr") - and node.args[1].s == "__call__" # noqa: W503 + and node.args[1].s == "__call__" ): self.errors.append(B004(node.lineno, node.col_offset)) if ( node.func.id == "getattr" - and len(node.args) == 2 # noqa: W503 - and _is_identifier(node.args[1]) # noqa: W503 - and not iskeyword(node.args[1].s) # noqa: W503 + and len(node.args) == 2 + and _is_identifier(node.args[1]) + and not iskeyword(node.args[1].s) ): self.errors.append(B009(node.lineno, node.col_offset)) elif ( node.func.id == "setattr" - and len(node.args) == 3 # noqa: W503 - and _is_identifier(node.args[1]) # noqa: W503 - and not iskeyword(node.args[1].s) # noqa: W503 + and len(node.args) == 3 + and _is_identifier(node.args[1]) + and not iskeyword(node.args[1].s) ): self.errors.append(B010(node.lineno, node.col_offset)) @@ -498,12 +498,12 @@ def check_for_b017(self, node): item_context = item.context_expr if ( hasattr(item_context, "func") - and hasattr(item_context.func, "attr") # noqa W503 - and item_context.func.attr == "assertRaises" # noqa W503 - and len(item_context.args) == 1 # noqa W503 - and isinstance(item_context.args[0], ast.Name) # noqa W503 - and item_context.args[0].id == "Exception" # noqa W503 - and not item.optional_vars # noqa W503 + and hasattr(item_context.func, "attr") + and item_context.func.attr == "assertRaises" + and len(item_context.args) == 1 + and isinstance(item_context.args[0], ast.Name) + and item_context.args[0].id == "Exception" + and not item.optional_vars ): self.errors.append(B017(node.lineno, node.col_offset)) @@ -587,7 +587,7 @@ def check_for_b902(self, node): if "type" in bases: if ( "classmethod" in decorators.names - or node.name in B902.implicit_classmethods # noqa: W503 + or node.name in B902.implicit_classmethods ): expected_first_args = B902.metacls kind = "metaclass class" @@ -597,7 +597,7 @@ def check_for_b902(self, node): else: if ( "classmethod" in decorators.names - or node.name in B902.implicit_classmethods # noqa: W503 + or node.name in B902.implicit_classmethods ): expected_first_args = B902.cls kind = "class" @@ -642,16 +642,16 @@ def check_for_b903(self, node): body = node.body if ( body - and isinstance(body[0], ast.Expr) # noqa: W503 - and isinstance(body[0].value, ast.Str) # noqa: W503 + and isinstance(body[0], ast.Expr) + and isinstance(body[0].value, ast.Str) ): # Ignore the docstring body = body[1:] if ( len(body) != 1 - or not isinstance(body[0], ast.FunctionDef) # noqa: W503 - or body[0].name != "__init__" # noqa: W503 + or not isinstance(body[0], ast.FunctionDef) + or body[0].name != "__init__" ): # only classes with *just* an __init__ method are interesting return diff --git a/setup.cfg b/setup.cfg index cf6b89f..2cf2711 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [flake8] # Keep in sync with .flake8. This copy here is needed for source packages # to be able to pass tests without failing selfclean check. -ignore = E203, E302, E501, E999 +ignore = E203, E302, E501, E999, W503 max-line-length = 88 max-complexity = 12 select = B,C,E,F,W,B9