Skip to content

Commit

Permalink
fix typo in unused comparison (B015) message (PyCQA#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslamb authored and jakkdl committed Nov 7, 2022
1 parent e81c636 commit bc96642
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.rst
Expand Up @@ -297,6 +297,10 @@ MIT
Change Log
----------

Future
~~~~~~~~~
* B027: ignore @overload when typing is import with other names

22.10.27
~~~~~~~~~

Expand Down
7 changes: 2 additions & 5 deletions bugbear.py
Expand Up @@ -671,10 +671,7 @@ def is_abstract_decorator(expr):

def is_overload(expr):
return (isinstance(expr, ast.Name) and expr.id == "overload") or (
isinstance(expr, ast.Attribute)
and isinstance(expr.value, ast.Name)
and expr.value.id == "typing"
and expr.attr == "overload"
isinstance(expr, ast.Attribute) and expr.attr == "overload"
)

def empty_body(body) -> bool:
Expand Down Expand Up @@ -1239,7 +1236,7 @@ def visit_Lambda(self, node):
}
B015 = Error(
message=(
"B015 Result of comparison is not used. This line doesn't do"
"B015 Result of comparison is not used. This line doesn't do "
"anything. Did you intend to prepend it with assert?"
)
)
Expand Down
13 changes: 12 additions & 1 deletion tests/b027.py
Expand Up @@ -60,7 +60,10 @@ def empty_2(self): # safe


# ignore @overload, fixes issue #304
# ignore overload with other imports, fixes #308
import typing
import typing as t
import typing as anything
from typing import Union, overload


Expand All @@ -73,6 +76,14 @@ def empty_1(self, foo: str):
def empty_1(self, foo: int):
...

@t.overload
def empty_1(self, foo: list):
...

@anything.overload
def empty_1(self, foo: float):
...

@abstractmethod
def empty_1(self, foo: Union[str, int]):
def empty_1(self, foo: Union[str, int, list, float]):
...

0 comments on commit bc96642

Please sign in to comment.