Skip to content

Commit

Permalink
fixup! fix construction of in-place properties
Browse files Browse the repository at this point in the history
  • Loading branch information
temyurchenko committed Sep 10, 2024
1 parent b659f1f commit 3dfd5ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions astroid/brain/brain_builtin_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,8 +648,10 @@ def infer_property(
name="<property>",
lineno=node.lineno,
col_offset=node.col_offset,
# ↓ semantically, the definition of this property isn't within
# node.frame (or anywhere else, really)
# ↓ semantically, the definition of the class of property isn't within
# node.frame. It's somewhere in the builtins module, but we are special
# casing it for each "property()" call, so we are making up the
# definition on the spot, ad-hoc.
parent=AstroidManager().adhoc_module,
)
prop_func.postinit(
Expand Down
5 changes: 3 additions & 2 deletions tests/brain/test_builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ def getter():
self.assertIsInstance(class_parent, nodes.ClassDef)
self.assertFalse(
any(
isinstance(getter, objects.Property)
for getter in class_parent.locals["getter"]
isinstance(def_, objects.Property)
for def_list in class_parent.locals.values()
for def_ in def_list
)
)
self.assertTrue(hasattr(inferred_property, "args"))
Expand Down

0 comments on commit 3dfd5ff

Please sign in to comment.