Skip to content

Commit

Permalink
Support typing comments for individual arguments. Close #3112
Browse files Browse the repository at this point in the history
  • Loading branch information
PCManticore committed Sep 23, 2019
1 parent 454c9ba commit 42d2d4b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pylint/checkers/variables.py
Expand Up @@ -1203,6 +1203,10 @@ def leave_assign(self, node):
def leave_with(self, node):
self._store_type_annotation_names(node)

def visit_arguments(self, node):
for annotation in node.type_comment_args:
self._store_type_annotation_node(annotation)

# Relying on other checker's options, which might not have been initialized yet.
@decorators.cachedproperty
def _analyse_fallback_blocks(self):
Expand Down
9 changes: 9 additions & 0 deletions tests/functional/u/unused_typing_imports.py
Expand Up @@ -15,6 +15,7 @@
NamedTuple,
Optional,
Pattern,
Sequence,
Set,
Tuple,
)
Expand Down Expand Up @@ -54,3 +55,11 @@ def typing_fully_qualified():
variable = None # type: typing.Optional[str]
other_variable: 'typing.Optional[str]' = None
return variable, other_variable


def function(arg1, # type: Iterable
arg2 # type: List
):
# type: (...) -> Sequence
"""docstring"""
print(arg1, arg2)

0 comments on commit 42d2d4b

Please sign in to comment.