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

Change order of search path to fix inconsistency between pylint and astroid. #2589

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

akamat10
Copy link
Contributor

Type of Changes

Type
βœ“ πŸ› Bug fix

Description

While testing pylint-dev/pylint#9967, I noticed that the qualified package names are incorrect when linted files are outside of the source-roots specified. This PR changes the priority of the search path which then correctly picks up the right qualified module name. It makes sense to give higher priority to the additional search paths over sys.path. This is in line with priority order of expand_modules function in pylint. Hopefully the maintainers agree that this inconsistency needs to be fixed.

Refs pylint-dev/pylint#9955

@akamat10
Copy link
Contributor Author

Also, both expand_module in pylint and modpath_from_file_with_callback in astroid are taking sys.path for module discovery with expand_module calling modpath_from_file_with_callback. It may be makes sense to simplify such that it is only happening in one of these functions

@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Bug πŸͺ³ and removed Enhancement ✨ Improvement to a component labels Sep 30, 2024
@Pierre-Sassoulas
Copy link
Member

Yeah let's make pylint rely on astroid's fonction or at least comment on the similarity if we want to reduce coupling.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests βœ…

Project coverage is 93.24%. Comparing base (62c5bad) to head (0a8ebeb).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2589   +/-   ##
=======================================
  Coverage   93.24%   93.24%           
=======================================
  Files          93       93           
  Lines       11067    11067           
=======================================
  Hits        10319    10319           
  Misses        748      748           
Flag Coverage Ξ”
linux 93.12% <100.00%> (ΓΈ)
pypy 93.24% <100.00%> (ΓΈ)
windows 93.22% <100.00%> (ΓΈ)

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

Files with missing lines Coverage Ξ”
astroid/modutils.py 89.47% <100.00%> (ΓΈ)

@akamat10
Copy link
Contributor Author

Great! Let me add a test with this PR before this is merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants