-
-
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
Issues linting project installed in editable mode #8829
Comments
Which version of |
If you look at the instruction in my reproducer, I'm upgrading to the latest pip. My project uses The more relevant detail I forgot to mention is that the package get installed with the new PEP 660 stuff. This means setuptools is creating a |
Now I can confirm the build backend is using setuptools 68.0.0 to install the package in editable mode. |
I probably won't have time to look into this in the next month due to holidays, sorry! It should have been fixed with pylint-dev/astroid#1752 but apparently it broke again? Or |
Hit this issue today in pylint extension with vscode, can confirm the package resolution only fails when the package is installed with Linking #4057 to help others find this issue |
#8896 gives a reproducer. |
I debugged this a bit, and it looks like pylint-dev/astroid#1752 does not deal with Furthermore it does not pass the full module path to So, an editable package with a namespace package root will not work. This seems to fix it: diff --git a/astroid/interpreter/_import/spec.py b/astroid/interpreter/_import/spec.py
index 5a7c4e82..4b90339e 100644
--- a/astroid/interpreter/_import/spec.py
+++ b/astroid/interpreter/_import/spec.py
@@ -390,7 +390,7 @@ def _find_spec_with_path(
return finder_instance, spec
# Support for custom finders
- for meta_finder in sys.meta_path:
+ for meta_finder in sys.meta_path + sys.path_hooks:
# See if we support the customer import hook of the meta_finder
meta_finder_name = meta_finder.__class__.__name__
if meta_finder_name not in _MetaPathFinderModuleTypes:
@@ -413,7 +413,8 @@ def _find_spec_with_path(
if not hasattr(meta_finder, "find_spec"):
continue
- spec = meta_finder.find_spec(modname, submodule_path)
+ full_name = ".".join(module_parts)
+ spec = meta_finder.find_spec(full_name, submodule_path)
if spec:
return (
meta_finder, But I'm not confident that I understand everything properly to send a PR to the astroid repository. |
Please do send a PR! I can help with reviewing (and will). Nobody understands this (clearly) but any help or collaboration will bring us closer to doing so 😄 |
After the release of pylint 3.2.2 and astroid 3.2.2, the issue seems to be fixed. |
Thank you for triaging @dalcinl ! |
Bug description
After installing my
pyproject.toml
project in editable mode, running pylint on the project's top level source directory seems to be broken. I experienced similar problems some time ago, see #7365.Configuration
No response
Command used
Pylint output
Expected behavior
Pylint version
OS / Environment
Fedora 38
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: