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 @@ -17,6 +17,11 @@ Release date: TBA
17
17
18
18
Closes #2734
19
19
20
+ * Fix a crash when parsing a slice called in a decorator on a function that is also decorated with
21
+ a known ``six`` decorator.
22
+
23
+ Closes #2721
24
+
20
25
What's New in astroid 3.3.10?
21
26
=============================
22
27
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 @@ -503,3 +503,19 @@ def test_regression_no_crash_during_build() -> None:
503
503
node : nodes .Attribute = extract_node ("__()" )
504
504
assert node .args == []
505
505
assert node .as_string () == "__()"
506
+
507
+
508
+ def test_regression_no_crash_on_called_slice () -> None :
509
+ """Regression test for issue #2721."""
510
+ node : nodes .Attribute = extract_node (
511
+ textwrap .dedent (
512
+ """
513
+ s = slice(-2)
514
+ @s()
515
+ @six.add_metaclass()
516
+ class a: ...
517
+ """
518
+ )
519
+ )
520
+ assert isinstance (node , nodes .ClassDef )
521
+ assert node .name == "a"
You can’t perform that action at this time.
0 commit comments