summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2019-09-23 09:37:25 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2019-09-23 09:37:25 +0200
commit42d2d4bebf2323508186b09e5c6531b8b9b1cc62 (patch)
treef8cb7216600088122a2f306c28b5c727779e2432
parent454c9bab1b40217b6844bede8017de4fcd310978 (diff)
downloadpylint-git-42d2d4bebf2323508186b09e5c6531b8b9b1cc62.tar.gz
Support typing comments for individual arguments. Close #3112
-rw-r--r--pylint/checkers/variables.py4
-rw-r--r--tests/functional/u/unused_typing_imports.py9
2 files changed, 13 insertions, 0 deletions
diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py
index 86fc47e82..d2b507e31 100644
--- a/pylint/checkers/variables.py
+++ b/pylint/checkers/variables.py
@@ -1203,6 +1203,10 @@ class VariablesChecker(BaseChecker):
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):
diff --git a/tests/functional/u/unused_typing_imports.py b/tests/functional/u/unused_typing_imports.py
index 6edca7153..add2316ce 100644
--- a/tests/functional/u/unused_typing_imports.py
+++ b/tests/functional/u/unused_typing_imports.py
@@ -15,6 +15,7 @@ from typing import (
NamedTuple,
Optional,
Pattern,
+ Sequence,
Set,
Tuple,
)
@@ -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)