File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,11 @@ Release date: TBA
41
41
42
42
Closes #2734
43
43
44
+ * Fix a crash when parsing a slice called in a decorator on a function that is also decorated with
45
+ a known ``six`` decorator.
46
+
47
+ Closes #2721
48
+
44
49
What's New in astroid 3.3.10?
45
50
=============================
46
51
Release date: 2025-05-10
Original file line number Diff line number Diff line change @@ -182,7 +182,11 @@ def transform_six_add_metaclass(node): # pylint: disable=inconsistent-return-st
182
182
func = next (decorator .func .infer ())
183
183
except (InferenceError , StopIteration ):
184
184
continue
185
- if func .qname () == SIX_ADD_METACLASS and decorator .args :
185
+ if (
186
+ isinstance (func , (nodes .FunctionDef , nodes .ClassDef ))
187
+ and func .qname () == SIX_ADD_METACLASS
188
+ and decorator .args
189
+ ):
186
190
metaclass = decorator .args [0 ]
187
191
node ._metaclass = metaclass
188
192
return node
Original file line number Diff line number Diff line change @@ -504,3 +504,19 @@ def test_regression_no_crash_during_build() -> None:
504
504
node : nodes .Attribute = extract_node ("__()" )
505
505
assert node .args == []
506
506
assert node .as_string () == "__()"
507
+
508
+
509
+ def test_regression_no_crash_on_called_slice () -> None :
510
+ """Regression test for issue #2721."""
511
+ node : nodes .Attribute = extract_node (
512
+ textwrap .dedent (
513
+ """
514
+ s = slice(-2)
515
+ @s()
516
+ @six.add_metaclass()
517
+ class a: ...
518
+ """
519
+ )
520
+ )
521
+ assert isinstance (node , nodes .ClassDef )
522
+ assert node .name == "a"
You can’t perform that action at this time.
0 commit comments