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

Conversation

temyurchenko
Copy link
Contributor

A part of getting rid of non-Module roots, see #2536

Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.99%. Comparing base (20890b8) to head (3dfd5ff).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2553      +/-   ##
==========================================
- Coverage   92.99%   92.99%   -0.01%     
==========================================
  Files          93       93              
  Lines       11087    11086       -1     
==========================================
- Hits        10310    10309       -1     
  Misses        777      777              
Flag Coverage Δ
linux 92.87% <ø> (-0.01%) ⬇️
pypy 92.99% <ø> (-0.01%) ⬇️
windows 92.97% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
astroid/brain/brain_builtin_inference.py 92.06% <ø> (-0.02%) ⬇️

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Thanks!

I think this PR shows how much the separate PRs help. Much easier to reason about the changes here in such small scope. Thanks again for doing this!

@@ -14,17 +14,17 @@

class BuiltinsTest(unittest.TestCase):
def test_infer_property(self):
class_with_property = _extract_single_node(
property_assign = _extract_single_node(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shall we add a test that property doesn't end up in the locals of Something so we don't regress here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've changed the assert below to check that there are no Property nodes in the locals.

lineno=node.lineno,
col_offset=node.col_offset,
# ↓ semantically, the definition of this property isn't within
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you expand this a little? I think the explanation you gave in the base PR was very useful:
This is not the property being created but the definition of the property class/function itself. Which doesn't really exist.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've provided a more detailed explanation. Not sure how coherent it is to others though

This is an example of an in-place property: `bar = property(getter)`.
   They just create a nameless object, not the one with the name of
   the getter. Thus, the name was changed to
   "<property>". Furthermore, the definition of that property is not
   attached to any scope, as it's again nameless.

it's a part of the campaign to get rid of non-module roots
@temyurchenko
Copy link
Contributor Author

I think this PR shows how much the separate PRs help. Much easier to reason about the changes here in such small scope. Thanks again for doing this!

Glad it's helpful! and thank you for your time

Copy link
Collaborator

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

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

Awesome, comment is very clear now!

@DanielNoord DanielNoord merged commit 8364693 into pylint-dev:main Sep 10, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants