megalinter
megalinter copied to clipboard
pylint import-error in 6.9.x
Describe the bug Upgrading to 6.9.x caused the import-error to appear using pylint, manually installing the pylint package solves the issue
To Reproduce Steps to reproduce the behavior:
.mega-linter.yml
PYTHON_PYLINT_PRE_COMMANDS:
- command: pylint --version
- command: python3 -m pip install -r ./requirements.txt
docker run -it --rm -v $(pwd):/tmp/lint -w /tmp/lint oxsecurity/megalinter-python:v6.9.0
docker run -it --rm -v $(pwd):/tmp/lint -w /tmp/lint oxsecurity/megalinter-python:v6.9.1
[pylint] main.py --Error detail: ************* Module main main.py:4:0: E0401: Unable to import 'deps' (import-error) main.py:5:0: E0401: Unable to import 'more_deps' (import-error)
Working Installing the same version using pip solves the issue
PYTHON_PYLINT_PRE_COMMANDS:
- command: python3 -m pip install pylint==2.15.2
- command: python3 -m pylint --version
- command: python3 -m pip install -r ./requirements.txt
docker run -it --rm -v $(pwd):/tmp/lint -w /tmp/lint oxsecurity/megalinter-python:v6.9.1
[python3 -m pylint --version] in cwd [/tmp/lint] [Pre][PYTHON_PYLINT] pylint 2.15.2 astroid 2.12.9 Python 3.10.4 (main, Apr 20 2022, 01:09:52) [GCC 10.3.1 20211027]
Expected behavior A clear and concise description of what you expected to happen. Expected result would be that the installed pylint would work as expected
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
I noticed the same issue with MegaLinter own code... that I bravely solved by disabling the rule in .pylintrc
https://github.com/oxsecurity/megalinter/blob/c03f277586384c29d7c8ee69db9885d96e2d6145/.github/linters/.pylintrc#L58
Pylint is also installed with pip within MegaLinter image -> https://github.com/oxsecurity/megalinter/blob/c03f277586384c29d7c8ee69db9885d96e2d6145/Dockerfile#L148
And this is the same version 2.15.2-> https://github.com/oxsecurity/megalinter/actions/runs/3039329494/jobs/4894131986#step:4:959
I think what changes is your PRE_COMMAND command: python3 -m pip install -r ./requirements.txt
, import_error probably needs the project to be installed to look for packages.
As install can take time, I'm not sure it's a good idea to do it by default... but I can add some documentation (or you, if you want to make a PR ^^) in the related descriptor :) (example)
I don't know, I feel like this is something else. pylint is not managed the same way in v6.9.x python image, or dependency link is broken..
➜ ~ docker run --rm --entrypoint "" oxsecurity/megalinter-python:v6.8.0 pip freeze | grep pylint pylint==2.15.0 ➜ ~ docker run --rm --entrypoint "" oxsecurity/megalinter-python:v6.9.0 pip freeze | grep pylint ➜ ~ docker run --rm --entrypoint "" oxsecurity/megalinter-python:v6.9.1 pip freeze | grep pylint
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.
If you think this issue should stay open, please remove the O: stale 🤖
label or comment on the issue.