From 370ec100ba79633befb71b650bad2812496af535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:23:05 +0200 Subject: [PATCH] Fix --- pylint/checkers/variables.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pylint/checkers/variables.py b/pylint/checkers/variables.py index 9456251e5a..ef2d8c1889 100644 --- a/pylint/checkers/variables.py +++ b/pylint/checkers/variables.py @@ -19,7 +19,7 @@ from typing import TYPE_CHECKING, Any, NamedTuple import astroid -from astroid import extract_node, nodes +from astroid import bases, extract_node, nodes from astroid.nodes import _base_nodes from astroid.typing import InferenceResult @@ -2276,7 +2276,17 @@ def _loopvar_name(self, node: astroid.Name) -> None: inferred_return = utils.safe_infer(inferred_func.returns) if isinstance( inferred_return, nodes.FunctionDef - ) and inferred_return.qname() in {*TYPING_NORETURN, *TYPING_NEVER}: + ) and inferred_return.qname() in { + *TYPING_NORETURN, + *TYPING_NEVER, + "typing._SpecialForm", + }: + return + # typing_extensions.NoReturn returns a _SpecialForm + if ( + isinstance(inferred_return, bases.Instance) + and inferred_return.qname() == "typing._SpecialForm" + ): return maybe_walrus = utils.get_node_first_ancestor_of_type(node, nodes.NamedExpr)