diff --git a/astroid/transforms.py b/astroid/transforms.py index 5f0e533136..2ec576f897 100644 --- a/astroid/transforms.py +++ b/astroid/transforms.py @@ -78,7 +78,9 @@ def _transform(self, node: SuccessfulInferenceResult) -> SuccessfulInferenceResu def _visit(self, node: nodes.NodeNG) -> SuccessfulInferenceResult: for name in node._astroid_fields: value = getattr(node, name) - value = cast(_Vistables, value) + if TYPE_CHECKING: + value = cast(_Vistables, value) + visited = self._visit_generic(value) if visited != value: setattr(node, name, visited)