Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in place properties #2553

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixup! fix construction of in-place properties
  • Loading branch information
temyurchenko committed Sep 10, 2024
commit 3dfd5ffb2b489ef38abe18b9528875d75d0e7e6b
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
Loading