Skip to content

Move safe_infer() to util #2232

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

Merged
merged 4 commits into from
Jul 4, 2023

Conversation

jacobtylerwalls
Copy link
Member

Type of Changes

Type
βœ“ πŸ”¨ Refactoring

Description

Avoid some circular imports by moving safe_infer() to util. Discussed at #2171 (comment).

Also, Remove shims for OperationError in exceptions module

@jacobtylerwalls jacobtylerwalls added the Maintenance Discussion or action around maintaining astroid or the dev workflow label Jul 2, 2023
@jacobtylerwalls jacobtylerwalls added this to the 3.0.0a6 milestone Jul 2, 2023
@codecov
Copy link

codecov bot commented Jul 2, 2023

Codecov Report

Merging #2232 (80bc234) into main (7c90b58) will decrease coverage by 0.13%.
The diff coverage is 94.00%.

❗ Current head 80bc234 differs from pull request most recent head cbc4fb8. Consider uploading reports for the commit cbc4fb8 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2232      +/-   ##
==========================================
- Coverage   92.93%   92.80%   -0.13%     
==========================================
  Files          94       94              
  Lines       10926    10930       +4     
==========================================
- Hits        10154    10144      -10     
- Misses        772      786      +14     
Flag Coverage Ξ”
linux 92.56% <94.00%> (-0.13%) ⬇️
pypy 90.93% <94.00%> (-0.10%) ⬇️
windows 92.39% <94.00%> (-0.11%) ⬇️

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

Impacted Files Coverage Ξ”
astroid/__init__.py 100.00% <ΓΈ> (ΓΈ)
astroid/exceptions.py 97.50% <ΓΈ> (-0.09%) ⬇️
astroid/protocols.py 90.43% <ΓΈ> (-0.03%) ⬇️
astroid/raw_building.py 94.95% <ΓΈ> (-0.02%) ⬇️
astroid/helpers.py 93.54% <71.42%> (-1.00%) ⬇️
astroid/util.py 88.31% <94.11%> (+1.42%) ⬆️
astroid/arguments.py 99.23% <100.00%> (-0.01%) ⬇️
astroid/bases.py 87.93% <100.00%> (-0.04%) ⬇️
astroid/brain/brain_attrs.py 100.00% <100.00%> (ΓΈ)
astroid/brain/brain_builtin_inference.py 92.24% <100.00%> (-0.42%) ⬇️
... and 5 more

... and 1 file with indirect coverage changes

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.

Haven't look at the code, but on a higher level: does it make sense to move this to util/inference.py?
That way we could define safe_infer, infer_all and some of the other inference utilities we need in pylint into one shared "API".

@jacobtylerwalls
Copy link
Member Author

I'm open to it, but I'd want to think carefully about it. Are you suggesting importing the astroid helpers and using those in pylint instead of the pylint helpers? The pylint safe_infer is a lot fancier. Could be a potential performance hit to port it to astroid and use it all the time there.

@DanielNoord
Copy link
Collaborator

I'm open to it, but I'd want to think carefully about it. Are you suggesting importing the astroid helpers and using those in pylint instead of the pylint helpers? The pylint safe_infer is a lot fancier. Could be a potential performance hit to port it to astroid and use it all the time there.

That's a good concern indeed. Let's keep it as is in this PR.

DanielNoord
DanielNoord previously approved these changes Jul 4, 2023
@jacobtylerwalls
Copy link
Member Author

Thanks for the review!

@jacobtylerwalls
Copy link
Member Author

I'll squash in the precommit fix. I undid it locally because I wasn't altering that code and figured I was on a newer version of ruff locally, but I guess not.

I'll add a test for the deprecation warning while at it

safe_infer() was moved to astroid.util
@jacobtylerwalls jacobtylerwalls enabled auto-merge (rebase) July 4, 2023 13:51
@jacobtylerwalls
Copy link
Member Author

Missing line is just being moved from one location to another, so overriding the patch coverage check.

@jacobtylerwalls jacobtylerwalls disabled auto-merge July 4, 2023 14:04
@jacobtylerwalls jacobtylerwalls merged commit bf4d420 into pylint-dev:main Jul 4, 2023
@jacobtylerwalls jacobtylerwalls deleted the move-safe-infer branch July 4, 2023 14:04
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.

2 participants