-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 source root not recognized #10036
Conversation
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #10036 +/- ##
=======================================
Coverage 95.80% 95.80%
=======================================
Files 174 174
Lines 18937 18937
=======================================
Hits 18143 18143
Misses 794 794
|
This comment has been minimized.
This comment has been minimized.
Thanks for the fix! Are you able to add a test for this as well? |
Thank you, I will take a look into it this week! |
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
Could you fix CI for the style and changeling checks? I think the PR itself looks really good already, thanks! π |
Thank you, typo should be fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @Julfried thank you for fixing the typo, do you mind adding a fragment for the changelog please ?
Here: https://github.com/pylint-dev/pylint/tree/main/doc/whatsnew/fragments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Thank you. The fragment should be added! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 93f980b |
Hi! I stumbled upon the same issue that this PR solves. Using a pylint version installed with a git url+hash through pip makes using source-roots work. Since it is not published yet, do you have any guidance on how source-roots should have been used originally? I can't find any usage pattern that would make it work at all according to the couple sentences present in the docs. I tried for hours now stepping through "/usr/local/python/3.12.7/lib/python3.12/site-packages/pylint/lint/expand_modules.py:discover_package_path()" with different combinations of invocations trying to have one that would match the one when using the developpement version ( If there's absolutely no workaround, can you consider backporting this specific fix to a version that would be released sooner? |
(cherry picked from commit be53085)
Hi @echoix I've created #10083 to backport, waiting for the opinion of other maintainers before merging because this is a part that is hard to test and historically caused a lot of problem (maybe not well suited to a patch release). While waiting for the release you can use an install using git for example: |
Thanks @Pierre-Sassoulas! Indeed the git version could be used, but at some point to finish off my PR I should need a release at one point. |
What I did in a project where I had this issue recently was to modify the python path with an init hook to add the source root to it |
Ours is quite sensitive to paths, as it uses some installed library and already have difficulty making normal imports work correctly... (we're working on it). The old way called Pylint 3 times, and had to be in different directories, with settings for each, not really easy to use for every contributor. |
You can list disable in the pylintrc, or at the top of files and progressively delete them. Not ideal, I know. There's #5403 |
(cherry picked from commit be53085) Co-authored-by: Julfried <[email protected]>
This patch modifies the `test_discover_package_path_source_root_as_*` tests to also run against directory layouts with no exlicitly existing `__init__.py` file. They were added in pylint-dev#10036 and seem to be insufficient, not covering PEP 420 implicit namespaces.
This patch modifies the `test_discover_package_path_source_root_as_*` tests to also run against directory layouts with no exlicitly existing `__init__.py` file. They were added in #10036 and seem to be insufficient, not covering PEP 420 implicit namespaces.
Type of Changes
Description
Closes #10026
This PR fixes a bug in the
discover_package_path
function in pylint/pyreverse. The function was incorrectly handling cases where the source root is a child of the module directory, causing issues when using pyreverse with certain project structures, particularly those with asrc
layout.The fix modifies the condition for identifying the correct source root, allowing it to handle both cases where the source root is a parent or a child of the module directory.
Changes made:
discover_package_path
function to correctly identify the source root: