From 908c3849efd1754df2b3ba2fc55e00890ae05b31 Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Sat, 15 Jul 2023 04:12:49 -0400 Subject: [PATCH] Let `TypeAlias` be a statement (#2250) Follow-up to fbcff3a5b559acb834bca23215a49ded3386f5bd. --- astroid/nodes/node_classes.py | 2 +- tests/test_type_params.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/astroid/nodes/node_classes.py b/astroid/nodes/node_classes.py index f22815555e..fc09829c94 100644 --- a/astroid/nodes/node_classes.py +++ b/astroid/nodes/node_classes.py @@ -4010,7 +4010,7 @@ def getitem(self, index, context: InferenceContext | None = None): return _container_getitem(self, self.elts, index, context=context) -class TypeAlias(_base_nodes.AssignTypeNode): +class TypeAlias(_base_nodes.AssignTypeNode, _base_nodes.Statement): """Class representing a :class:`ast.TypeAlias` node. >>> import astroid diff --git a/tests/test_type_params.py b/tests/test_type_params.py index b5827010cd..6ce5e6877a 100644 --- a/tests/test_type_params.py +++ b/tests/test_type_params.py @@ -35,6 +35,8 @@ def test_type_alias() -> None: assert node.inferred()[0] is node assert node.type_params[0].inferred()[0] is node.type_params[0] + assert node.statement() is node + def test_type_param_spec() -> None: node = extract_node("type Alias[**P] = Callable[P, int]")