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

make constants have synthetic root as their parent #2602

Merged
merged 3 commits into from
Oct 13, 2024

Conversation

temyurchenko
Copy link
Contributor

that fixes a bunch of tests in pylint.

We also make the synthetic root a singleton, as opposed to a module
built in the astroid manager. That allows us to use it as a default
value in Const constructors.

Note the changes to the test. Before, we in fact tested that constants
don't have a parent. Is that reasonable? In fact, it seems like
there are a variety of interpretations and we shouldn't commit to
one by explicitly testing for a certain parent or lack thereof.

Type of Changes

Type
🐛 Bug fix

@temyurchenko
Copy link
Contributor Author

This has in fact uncovered several incorrect tests in pylint, a PR for which I'll make later

that fixes a bunch of tests in pylint.

We also make the synthetic root a singleton, as opposed to a module
   built in the astroid manager. That allows us to use it as a default
   value in Const constructors.

Note the changes to the test. Before, we in fact tested that constants
   don't have a parent. Is that reasonable? In fact, it seems like
   there are a variety of interpretations and we shouldn't commit to
   one by explicitly testing for a certain parent or lack thereof.
Copy link

codecov bot commented Oct 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.25%. Comparing base (275f508) to head (c68607a).
Report is 7 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2602   +/-   ##
=======================================
  Coverage   93.24%   93.25%           
=======================================
  Files          93       93           
  Lines       11049    11070   +21     
=======================================
+ Hits        10303    10323   +20     
- Misses        746      747    +1     
Flag Coverage Δ
linux 93.14% <100.00%> (+0.01%) ⬆️
pypy 93.25% <100.00%> (+<0.01%) ⬆️
windows 93.25% <100.00%> (+0.02%) ⬆️

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

Files with missing lines Coverage Δ
astroid/brain/brain_argparse.py 95.83% <ø> (ø)
astroid/brain/brain_builtin_inference.py 92.03% <ø> (-0.04%) ⬇️
astroid/brain/brain_namedtuple_enum.py 93.88% <100.00%> (+0.02%) ⬆️
astroid/manager.py 89.87% <ø> (-0.13%) ⬇️
astroid/nodes/__init__.py 100.00% <ø> (ø)
astroid/nodes/node_classes.py 95.14% <100.00%> (+<0.01%) ⬆️
astroid/nodes/scoped_nodes/__init__.py 100.00% <ø> (ø)
astroid/nodes/scoped_nodes/scoped_nodes.py 93.68% <100.00%> (+0.34%) ⬆️
astroid/objects.py 94.26% <ø> (ø)

... and 5 files with indirect coverage changes

@temyurchenko temyurchenko force-pushed the set-constant-roots branch 3 times, most recently from 96b5d73 to eab2b06 Compare October 7, 2024 06:22
Copy link
Member

@jacobtylerwalls jacobtylerwalls left a comment

Choose a reason for hiding this comment

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

Thanks for this important cleanup and for the follow-through with the pylint PR to fix tests. By new year or so I imagine we'll issue an alpha of astroid-4.0 so we can use it on pylint main and merge those test fixes.

@@ -248,7 +248,7 @@ def with_metaclass(meta, *bases):
class metaclass(meta):
def __new__(cls, name, this_bases, d):
return meta(name, bases, d)
return type.__new__(metaclass, 'temporary_class', (), {})
return type.__new__(metaclass, 'temporary_class', (), {})
Copy link
Member

Choose a reason for hiding this comment

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

Hopefully the crash referred to in the bitbucket issue that has been lost to time didn't depend on this syntax error. 🙏

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From my understanding, the only part that mattered was the «six.with_metaclass» in the line below. The piece of code above could have been either simplified significantly or omitted altogether

Copy link
Member

Choose a reason for hiding this comment

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

Ugh. Thanks for looking into it.

@jacobtylerwalls jacobtylerwalls enabled auto-merge (squash) October 13, 2024 21:12
@jacobtylerwalls jacobtylerwalls added this to the 4.0.0 milestone Oct 13, 2024
@temyurchenko
Copy link
Contributor Author

Give me a moment to squash the fixup commit

@jacobtylerwalls jacobtylerwalls added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Oct 13, 2024
@jacobtylerwalls
Copy link
Member

Sure, I'll disable auto-squash, but just so you know my plan was to squash all three commits and use the original message minus the question about the test. Would that have been okay?

@temyurchenko
Copy link
Contributor Author

Sure, I'll disable auto-squash, but just so you know my plan was to squash all three commits and use the original message minus the question about the test. Would that have been okay?

Ah, absolutely fine.

@jacobtylerwalls jacobtylerwalls merged commit 7710b7b into pylint-dev:main Oct 13, 2024
21 checks passed
@temyurchenko
Copy link
Contributor Author

By new year or so I imagine we'll issue an alpha of astroid-4.0 so we can use it on pylint main and merge those test fixes.

Hey, can we somehow mark the pylint PR (pylint-dev/pylint#10013) as being necessary to merge with astroid 4.0? Otherwise, there will be confusion about why the tests are failing and there is no obvious indication that they are fixed by that PR.

@temyurchenko temyurchenko deleted the set-constant-roots branch October 15, 2024 21:25
@DanielNoord
Copy link
Collaborator

I have added labels that should help identify it as being necessary :)

@temyurchenko
Copy link
Contributor Author

I have added labels that should help identify it as being necessary :)

Thank you!

cdce8p pushed a commit to cdce8p/astroid that referenced this pull request Nov 4, 2024
that fixes a bunch of tests in pylint.

We also make the synthetic root a singleton, as opposed to a module
   built in the astroid manager. That allows us to use it as a default
   value in Const constructors.
cdce8p pushed a commit to cdce8p/astroid that referenced this pull request Nov 4, 2024
that fixes a bunch of tests in pylint.

We also make the synthetic root a singleton, as opposed to a module
   built in the astroid manager. That allows us to use it as a default
   value in Const constructors.
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