-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Use importlib
instead of pkg_resources
for determining namespace packages
#1326
Conversation
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.
LGTM. Let's see what comes of the bug you opened.
2e8aae8
to
d037e97
Compare
This was actually quite difficult to get right and I'm not sure I'm quite there yet. I'm especially wondering if the handling of the I also wonder if the |
importlib
instead of pkg_resources
for determinig namespace packagesimportlib
instead of pkg_resources
for determining namespace packages
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.
I have a hard time reviewing this, this is a delicate part of the code as there was a lot of issue with namespace package and __init__.py
in the past. On the other hand I would love to reduce astroid start up time 😄
we might want to gather feedback?
Yes, but how would we do that ? Asking user to install this branch ? Temporary more primer tests in pylint ?
Also, should we keep this in astroid 2.10 ? I'd like to release pylint 2.13, maybe there's some issue that are not strictly necessary. To be honest I'm afraid of merging this so I let it go stale but having 300+ issues in pylint 2.13 milestone is not ideal.
I'm wondering if this is actually used that often in If not, then this is just a more elaborate function which just hides the import of
I mean: I would think it makes sense. It would be a nice performance increase. |
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.
Let's merge then :) Do you think it's ready ?
I think so. I only worry a little about the handling of the |
This PR seems to cause a major performance regression. I only have the Github Action numbers for Home-Assistant to compare with, but there I'm seeing a 35% slower test run (with 2 jobs). Furthermore, I noticed unexpected debug log messages which might suggest packages are actually imported at runtime instead of only analyzed. Some examples:
|
That's definetly not good. Sorry about that. My first thought is that it might be due to |
Maybe we can check if |
…age discovery (pylint-dev#1326)" This reverts commit 8f477fd.
Steps
Description
Work in progress.
I don't think we can fully remove
pkg_resources
just yet. There are two test cases that fail withoutis_old_setuptools_namespace_package
.However, I think those might be non-sensical as that interfere with
_namespace_packages
directly instead of actually registering any packages. I tested this and this works withoutis_old_setuptools_namespace_package
for normally registeredsetuptools namespace package
's.I also ran into a weird bug with
find_spec
that I have filed to see if I'm doing anything wrong.Type of Changes
Related Issue
Ref #1103