File tree Expand file tree Collapse file tree 3 files changed +27
-0
lines changed
astroid/nodes/scoped_nodes Expand file tree Collapse file tree 3 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ What's New in astroid 3.2.3?
16
16
============================
17
17
Release date: TBA
18
18
19
+ * Fix ``AssertionError`` when inferring a property consisting of a partial function.
20
+
21
+ Closes pylint-dev/pylint#9214
22
+
19
23
20
24
What's New in astroid 3.2.2?
21
25
============================
Original file line number Diff line number Diff line change @@ -2518,6 +2518,10 @@ def igetattr(
2518
2518
elif isinstance (inferred , objects .Property ):
2519
2519
function = inferred .function
2520
2520
if not class_context :
2521
+ if not context .callcontext :
2522
+ context .callcontext = CallContext (
2523
+ args = function .args .arguments , callee = function
2524
+ )
2521
2525
# Through an instance so we can solve the property
2522
2526
yield from function .infer_call_result (
2523
2527
caller = self , context = context
Original file line number Diff line number Diff line change @@ -477,3 +477,22 @@ def test_recursion_during_inference(mocked) -> None:
477
477
with pytest .raises (InferenceError ) as error :
478
478
next (node .infer ())
479
479
assert error .value .message .startswith ("RecursionError raised" )
480
+
481
+
482
+ def test_regression_missing_callcontext () -> None :
483
+ node : nodes .Attribute = _extract_single_node (
484
+ textwrap .dedent (
485
+ """
486
+ import functools
487
+
488
+ class MockClass:
489
+ def _get_option(self, option):
490
+ return "mystr"
491
+
492
+ enabled = property(functools.partial(_get_option, option='myopt'))
493
+
494
+ MockClass().enabled
495
+ """
496
+ )
497
+ )
498
+ assert node .inferred ()[0 ].value == "mystr"
You can’t perform that action at this time.
0 commit comments