File tree 3 files changed +23
-15
lines changed
3 files changed +23
-15
lines changed Original file line number Diff line number Diff line change @@ -223,6 +223,16 @@ Release date: TBA
223
223
Closes pylint-dev/pylint#9015
224
224
225
225
226
+ What's New in astroid 2.15.8?
227
+ =============================
228
+ Release date: TBA
229
+
230
+ * Fix a regression in 2.15.7 for ``unsubscriptable-object``.
231
+
232
+ Closes #2305
233
+ Closes pylint-dev/pylint#9069
234
+
235
+
226
236
What's New in astroid 2.15.7?
227
237
=============================
228
238
Release date: 2023-09-23
Original file line number Diff line number Diff line change 17
17
from astroid .builder import AstroidBuilder , _extract_single_node
18
18
from astroid .const import PY39_PLUS , PY312_PLUS
19
19
from astroid .exceptions import (
20
+ AstroidSyntaxError ,
20
21
AttributeInferenceError ,
21
22
InferenceError ,
22
23
UseInferenceDefault ,
@@ -136,14 +137,10 @@ def infer_typing_typevar_or_newtype(
136
137
raise UseInferenceDefault
137
138
138
139
typename = node .args [0 ].as_string ().strip ("'" )
139
- node = ClassDef (
140
- name = typename ,
141
- lineno = node .lineno ,
142
- col_offset = node .col_offset ,
143
- parent = node .parent ,
144
- end_lineno = node .end_lineno ,
145
- end_col_offset = node .end_col_offset ,
146
- )
140
+ try :
141
+ node = extract_node (TYPING_TYPE_TEMPLATE .format (typename ))
142
+ except AstroidSyntaxError as exc :
143
+ raise InferenceError from exc
147
144
return node .infer (context = context_itton )
148
145
149
146
Original file line number Diff line number Diff line change 2
2
# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE
3
3
# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt
4
4
5
- from astroid import builder , nodes
5
+ import pytest
6
+
7
+ from astroid import builder
8
+ from astroid .exceptions import InferenceError
6
9
7
10
8
11
def test_infer_typevar () -> None :
@@ -12,13 +15,11 @@ def test_infer_typevar() -> None:
12
15
Test that an inferred `typing.TypeVar()` call produces a `nodes.ClassDef`
13
16
node.
14
17
"""
15
- assign_node = builder .extract_node (
18
+ call_node = builder .extract_node (
16
19
"""
17
20
from typing import TypeVar
18
- MyType = TypeVar('My.Type')
21
+ TypeVar('My.Type')
19
22
"""
20
23
)
21
- call = assign_node .value
22
- inferred = next (call .infer ())
23
- assert isinstance (inferred , nodes .ClassDef )
24
- assert inferred .name == "My.Type"
24
+ with pytest .raises (InferenceError ):
25
+ call_node .inferred ()
You can’t perform that action at this time.
0 commit comments