-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
ImportWarning due to usage of deprecated method #703
ImportWarning due to usage of deprecated method #703
Comments
Hm, spent again an hour fighting with this just to end up finding my own issue from 6 months ago :). The problem still persists with
Still, pylint keeps complaining about missing names when run through pytest-pylint in namespace packages so we need to keep adding |
In order to reproduce the issue one could use a
and then an
and a
If one then runs pytest we get an ugly error:
If one removes the |
@GergelyKalmar thanks for your report, investigations and associated PR. I'm unable to reproduce the bug.
I'm not so familiar with |
@hippo91 no worries at all! Did you create a virtual environment and installed the packages listed in |
In particular, you may want to execute this in the folder where the files are saved:
|
@GergelyKalmar thanks for your indications. 👍 I succeeded in reproducing the bug. BTW i answer to the PR. |
Steps to reproduce
It seems that the
importer.find_module
calls in the_search_zip
function emit an ImportWarning when namespace packages are encountered:https://github.com/PyCQA/astroid/blob/bff51e9d41a3084b9313fa2108ae13f079bc0b58/astroid/interpreter/_import/spec.py#L276-L292
This then breaks pytest-pylint runs in which warnings are turned into errors.
According to the importlib documentation
find_module
is deprecated and one should usefind_spec
instead. When patching the library locally this seems to have solved the issue with the namespace packages.Current behavior
An ImportWarning is raised and the namespace package does not get imported. For example:
ImportWarning: Not importing directory /home/.venv/lib/python3.5/site-packages/google: missing __init__
Expected behavior
The package gets imported and no ImportWarning is issued.
Version
astroid == 2.3.1
The text was updated successfully, but these errors were encountered: