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

astroid 2.9.1 breaks pylint with missing __init__.py: F0010: error while code parsing: Unable to load file __init__.py #1327

Closed
interifter opened this issue Jan 3, 2022 · 10 comments · Fixed by #1333
Milestone

Comments

@interifter
Copy link

interifter commented Jan 3, 2022

Steps to reproduce

Steps provided are for Windows 11, but initial problem found in Ubuntu 20.04

Update 2022-01-04: Corrected repro steps and added more environment details

  1. Set up simple repo with following structure (all files can be empty):
root_dir/
|--src/
|----project/ # Notice the missing __init__.py
|------file.py # It can be empty, but I added `import os` at the top
|----__init__.py
  1. Open a command prompt
  2. cd root_dir
  3. python -m venv venv
  4. venv/Scripts/activate
  5. pip install pylint astroid==2.9.1 # I also repro'd on the latest, 2.9.2
  6. pylint src/project # Updated from pylint src
  7. Observe failure:
src\project\__init__.py:1:0: F0010: error while code parsing: Unable to load file src\project\__init__.py:

Current behavior

Fails with src\project\__init__.py:1:0: F0010: error while code parsing: Unable to load file src\project\__init__.py:

Expected behavior

Does not fail with error.

If you replace step 6 with pip install pylint astroid==2.9.0, you get no failure with an empty output - since no files have content

python -c "from astroid import __pkginfo__; print(__pkginfo__.version)" output

2.9.1

python 3.9.1
pylint 2.12.2

This issue has been observed with astroid 2.9.1 and 2.9.2

@DanielNoord
Copy link
Collaborator

I can't seem to reproduce this in my virtualenv. This might be specific to venv? Needs some further investigation.

@DanielNoord
Copy link
Collaborator

@interifter Which version of pylint are you using?

@Pierre-Sassoulas
Copy link
Member

Right, pip install pylint astroid==2.9.0, will keep the local version if you already have one, so I thought it was 2.12.2 but that could be false. In fact it probably isn't 2.12.2. For the record, you're not supposed to set the version of astroid yourself, pylint does, and bad thing will happen if you try to set the version of an incompatible astroid. We might want to update the issue's template to have this information next.

@interifter
Copy link
Author

interifter commented Jan 4, 2022

My apologies... I updated the repro steps with a critical missed detail: pylint src/project, instead of pylint src

But I verified that either with, or without, venv, the issue is reproduced.

Also, I never have specified the astroid version, before.

However, this isn't the first time the issue has been observed.
Back in early 2019, a similar issue was observed with either astroid 2.2.0 or isort 4.3.5, which led me to try pinning astroid==2.9.0, which worked.

@interifter
Copy link
Author

@interifter Which version of pylint are you using?

2.12.2

Full env info:

Package           Version
----------------- -------
astroid           2.9.2
colorama          0.4.4
isort             5.10.1
lazy-object-proxy 1.7.1
mccabe            0.6.1
pip               20.2.3
platformdirs      2.4.1
pylint            2.12.2
setuptools        49.2.1
toml              0.10.2
typing-extensions 4.0.1
wrapt             1.13.3

@hippo91
Copy link
Contributor

hippo91 commented Jan 8, 2022

I confirm the bug and i'm able to reproduce it with python 3.9.1.

$> pip freeze
astroid==2.9.2
isort==5.10.1
lazy-object-proxy==1.7.1
mccabe==0.6.1
platformdirs==2.4.1
pylint==2.12.2
toml==0.10.2
typing-extensions==4.0.1
wrapt==1.13.3

@DanielNoord
Copy link
Collaborator

DanielNoord commented Jan 8, 2022

Bisected and this is the faulty commit:
2ee20cc

@DanielNoord
Copy link
Collaborator

Fix in #1333, no time to write tests yet so if somebody has any good ideas: please let me know!

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.9.3 milestone Jan 9, 2022
@DanielNoord
Copy link
Collaborator

@interifter Fixed and released with 2.9.3. Thanks for the report and reproducible example. Not sure why I couldn't reproduce this to begin with.

@interifter
Copy link
Author

@DanielNoord I had the incorrect steps to reproduce when I initially filed the bug, so that likely would prevent you, or anyone else, from being able to :)

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

Successfully merging a pull request may close this issue.

4 participants