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

enforce a non-None parent in build_function #2562

Merged

Conversation

temyurchenko
Copy link
Contributor

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

We also remove add_local_node to avoid redundancy. Instead we do the
attachment to the parent scope in the constructor of FunctionDef.

We append a node to the body of the frame when it is also the
parent. If it's not a parent, then the node should belong to the
"body" of the parent if it existed. An example is a definition
within an "if", where the parent is the If node, but the frame is
the whole module.

it's a part of the campaign to get rid of non-module roots

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
📜 Docs

Description

Refs #XXXX

Closes #XXXX

@temyurchenko
Copy link
Contributor Author

Review #2564 first, please

Copy link

codecov bot commented Sep 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.22%. Comparing base (be00359) to head (680654c).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2562   +/-   ##
=======================================
  Coverage   93.22%   93.22%           
=======================================
  Files          93       93           
  Lines       11048    11048           
=======================================
  Hits        10300    10300           
  Misses        748      748           
Flag Coverage Δ
linux 93.11% <100.00%> (ø)
pypy 93.22% <100.00%> (ø)
windows 93.21% <100.00%> (ø)

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

Files with missing lines Coverage Δ
astroid/raw_building.py 94.58% <100.00%> (ø)

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.

This needs to be rebased and given a new name to the PR, but the localname change LGTM.

For posterity the localname stuff was introduced in 4cdfc82

If I understand it correctly, when doing the initial object_build we try to access getattr(obj, name).__name__ However, this can fail so the code was changed to also have a reference to name itself as a fallback.
The changes in this PR still allow this pattern so they look good. Please rebase so I can merge it.

@DanielNoord
Copy link
Collaborator

Never mind my previous comment. The second commit in this PR was merged in #2557.

The first commit was correctly split out to #2564 which I'll approve and merge shortly with the same comment.

@temyurchenko Is a commit missing from this PR? Or should it be closed/

@temyurchenko
Copy link
Contributor Author

Never mind my previous comment. The second commit in this PR was merged in #2557.

Hmm, no, that commit was about build_object. This one is about build_function. The changes are similar but applied to different symbols.

@temyurchenko
Copy link
Contributor Author

If I understand it correctly, when doing the initial object_build we try to access getattr(obj, name).__name__ However, this can fail so the code was changed to also have a reference to name itself as a fallback.

It doesn't exactly fail, it's just that in pypy they do stuff like list.__mul__ = list.__rmul__. And now even though list.__mul__ is accessed via __mul__ localname, it's actually the __rmul__ object with the corresponding .__name__.

@temyurchenko temyurchenko force-pushed the require-build_function-parent branch 3 times, most recently from b9d298b to 8c85892 Compare September 13, 2024 23:11
DanielNoord
DanielNoord previously approved these changes Sep 30, 2024
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.

Last commit in this PR (after rebase of course) LGTM!

@DanielNoord
Copy link
Collaborator

Could you rebase this so I can merge it? :)

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

Could you rebase this so I can merge it? :)

Done!

@Pierre-Sassoulas Pierre-Sassoulas merged commit 6dba72c into pylint-dev:main Oct 2, 2024
20 checks passed
@Pierre-Sassoulas Pierre-Sassoulas added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Maintenance Discussion or action around maintaining astroid or the dev workflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants