|
14 | 14 | from functools import cached_property, partial |
15 | 15 | from itertools import chain, groupby, zip_longest |
16 | 16 | from keyword import iskeyword |
17 | | -from typing import TYPE_CHECKING, Any, ClassVar, NamedTuple, Union |
| 17 | +from typing import TYPE_CHECKING, Any, ClassVar, NamedTuple, Protocol, Union |
18 | 18 |
|
19 | 19 | from flake8 import checker |
20 | 20 | from flake8.options.manager import OptionManager |
@@ -62,6 +62,11 @@ class TypeVarInfo(NamedTuple): |
62 | 62 | name: str |
63 | 63 |
|
64 | 64 |
|
| 65 | +class NodeWithLocation(Protocol): |
| 66 | + lineno: int |
| 67 | + col_offset: int |
| 68 | + |
| 69 | + |
65 | 70 | def all_equal(iterable: Iterable[object]) -> bool: |
66 | 71 | """Returns True if all the elements are equal to each other. |
67 | 72 |
|
@@ -2245,7 +2250,7 @@ def check_arg_default(self, arg: ast.arg, default: ast.expr | None) -> None: |
2245 | 2250 | if default is not None and not _is_valid_default_value_with_annotation(default): |
2246 | 2251 | self.error(default, (Y014 if arg.annotation is None else Y011)) |
2247 | 2252 |
|
2248 | | - def error(self, node: ast.AST, message: str) -> None: |
| 2253 | + def error(self, node: NodeWithLocation, message: str) -> None: |
2249 | 2254 | self.errors.append(Error(node.lineno, node.col_offset, message, PyiTreeChecker)) |
2250 | 2255 |
|
2251 | 2256 | def _check_for_unused_things(self) -> None: |
|
0 commit comments