@@ -3062,6 +3062,13 @@ def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
30623062 imported_name in self ._type_annotation_names
30633063 or as_name in self ._type_annotation_names
30643064 )
3065+
3066+ is_dummy_import = (
3067+ as_name
3068+ and self .linter .config .dummy_variables_rgx
3069+ and self .linter .config .dummy_variables_rgx .match (as_name )
3070+ )
3071+
30653072 if isinstance (stmt , nodes .Import ) or (
30663073 isinstance (stmt , nodes .ImportFrom ) and not stmt .modname
30673074 ):
@@ -3072,12 +3079,11 @@ def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
30723079 # because they can be imported for exporting.
30733080 continue
30743081
3075- if is_type_annotation_import :
3082+ if is_type_annotation_import or is_dummy_import :
30763083 # Most likely a typing import if it wasn't used so far.
3084+ # Also filter dummy variables.
30773085 continue
30783086
3079- if as_name == "_" :
3080- continue
30813087 if as_name is None :
30823088 msg = f"import { imported_name } "
30833089 else :
@@ -3095,8 +3101,9 @@ def _check_imports(self, not_consumed: dict[str, list[nodes.NodeNG]]) -> None:
30953101 # __future__ import in another module.
30963102 continue
30973103
3098- if is_type_annotation_import :
3104+ if is_type_annotation_import or is_dummy_import :
30993105 # Most likely a typing import if it wasn't used so far.
3106+ # Also filter dummy variables.
31003107 continue
31013108
31023109 if imported_name == "*" :
0 commit comments