Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ What's New in astroid 3.2.3?
============================
Release date: TBA

* Fix ``AssertionError`` when inferring a property consisting of a partial function.

Closes pylint-dev/pylint#9214


What's New in astroid 3.2.2?
============================
Expand Down
4 changes: 4 additions & 0 deletions astroid/nodes/scoped_nodes/scoped_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2518,6 +2518,10 @@ def igetattr(
elif isinstance(inferred, objects.Property):
function = inferred.function
if not class_context:
if not context.callcontext:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have the identical problem just below this, but I'm hesitant to just add it without a test case in hand. One thing at a time :-)

context.callcontext = CallContext(
args=function.args.arguments, callee=function
)
# Through an instance so we can solve the property
yield from function.infer_call_result(
caller=self, context=context
Expand Down
19 changes: 19 additions & 0 deletions tests/test_regrtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,3 +477,22 @@ def test_recursion_during_inference(mocked) -> None:
with pytest.raises(InferenceError) as error:
next(node.infer())
assert error.value.message.startswith("RecursionError raised")


def test_regression_missing_callcontext() -> None:
node: nodes.Attribute = _extract_single_node(
textwrap.dedent(
"""
import functools

class MockClass:
def _get_option(self, option):
return "mystr"

enabled = property(functools.partial(_get_option, option='myopt'))

MockClass().enabled
"""
)
)
assert node.inferred()[0].value == "mystr"