Skip to content

Commit

Permalink
fix: handle annotations in positional-only args
Browse files Browse the repository at this point in the history
  • Loading branch information
shiftinv committed Jul 8, 2022
1 parent 03e868c commit 7a5f727
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flake8_type_checking/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def register_function_annotations(self, node: Union[FunctionDef, AsyncFunctionDe
And we also note down the start and end line number for the function.
"""
for path in [node.args.args, node.args.kwonlyargs]:
for path in [node.args.args, node.args.kwonlyargs, node.args.posonlyargs]:
for argument in path:
if hasattr(argument, 'annotation') and argument.annotation:
self.add_annotation(argument.annotation)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_tc004.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ def example(*args: Any, **kwargs: Any):
),
set(),
),
(
textwrap.dedent(
"""
if TYPE_CHECKING:
from typing import List, Sequence, Set
def example(a: List[int], /, b: Sequence[int], *, c: Set[int]):
return
"""
),
set(),
),
# Used different places, but where each function scope has it's own import
(
textwrap.dedent(
Expand Down

0 comments on commit 7a5f727

Please sign in to comment.