Skip to content

Commit 964d63e

Browse files
Infer type param related nodes as themselves
1 parent b21f500 commit 964d63e

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

astroid/inference.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def infer_end(
9292
nodes.Lambda._infer = infer_end # type: ignore[assignment]
9393
nodes.Const._infer = infer_end # type: ignore[assignment]
9494
nodes.Slice._infer = infer_end # type: ignore[assignment]
95+
nodes.TypeAlias._infer = infer_end # type: ignore[assignment]
96+
nodes.TypeVar._infer = infer_end # type: ignore[assignment]
97+
nodes.ParamSpec._infer = infer_end # type: ignore[assignment]
9598

9699

97100
def _infer_sequence_helper(

tests/test_type_params.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,19 @@ def test_type_alias() -> None:
2222
assert node.value.slice.name == "tuple"
2323
assert all(elt.name == "float" for elt in node.value.slice.elts)
2424

25+
assert node.inferred()[0] is node
26+
assert node.type_params[0].inferred()[0] is node.type_params[0]
27+
2528

2629
@pytest.mark.skipif(not PY312_PLUS, reason="Requires Python 3.12 or higher")
2730
def test_type_param_spec() -> None:
2831
node = extract_node("type Alias[**P] = Callable[P, int]")
2932
params = node.type_params[0]
3033
assert isinstance(params, ParamSpec)
3134
assert params.name == "P"
32-
35+
36+
assert node.inferred()[0] is node
37+
3338

3439
@pytest.mark.skipif(not PY312_PLUS, reason="Requires Python 3.12 or higher")
3540
def test_type_param() -> None:

0 commit comments

Comments
 (0)