diff --git a/ChangeLog b/ChangeLog index 8d13de9f98..1fb8da2611 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,19 @@ Pylint's ChangeLog ------------------ +What's New in Pylint 2.4.4? +=========================== +Release date: TBA + +* Exempt all the names found in type annotations from ``unused-import`` + + The previous code was assuming that only ``typing`` names need to be + exempted, but we need to do that for the rest of the type comment + names as well. + + Close #3112 + + What's New in Pylint 2.4.3? =========================== diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index bc53fb9f50..c278bb859a 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -1693,7 +1693,6 @@ def _store_type_annotation_node(self, type_annotation): self._type_annotation_names.extend( annotation.name for annotation in type_annotation.nodes_of_class(astroid.Name) - if annotation.name in TYPING_NAMES ) def _store_type_annotation_names(self, node): diff --git a/tests/functional/u/unused_typing_imports.py b/tests/functional/u/unused_typing_imports.py index add2316ce5..4c122a6220 100644 --- a/tests/functional/u/unused_typing_imports.py +++ b/tests/functional/u/unused_typing_imports.py @@ -7,6 +7,7 @@ import re import typing +from datetime import datetime from typing import ( Any, Callable, @@ -63,3 +64,9 @@ def function(arg1, # type: Iterable # type: (...) -> Sequence """docstring""" print(arg1, arg2) + + +def magic(alpha, beta, gamma): + # type: (str, Optional[str], Optional[datetime]) -> Any + """going strong""" + return alpha, beta, gamma