Skip to content

Commit 3dfd5ff

Browse files
committed
fixup! fix construction of in-place properties
1 parent b659f1f commit 3dfd5ff

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

astroid/brain/brain_builtin_inference.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,10 @@ def infer_property(
648648
name="<property>",
649649
lineno=node.lineno,
650650
col_offset=node.col_offset,
651-
# ↓ semantically, the definition of this property isn't within
652-
# node.frame (or anywhere else, really)
651+
# ↓ semantically, the definition of the class of property isn't within
652+
# node.frame. It's somewhere in the builtins module, but we are special
653+
# casing it for each "property()" call, so we are making up the
654+
# definition on the spot, ad-hoc.
653655
parent=AstroidManager().adhoc_module,
654656
)
655657
prop_func.postinit(

tests/brain/test_builtin.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ def getter():
2828
self.assertIsInstance(class_parent, nodes.ClassDef)
2929
self.assertFalse(
3030
any(
31-
isinstance(getter, objects.Property)
32-
for getter in class_parent.locals["getter"]
31+
isinstance(def_, objects.Property)
32+
for def_list in class_parent.locals.values()
33+
for def_ in def_list
3334
)
3435
)
3536
self.assertTrue(hasattr(inferred_property, "args"))

0 commit comments

Comments
 (0)