Pylint passes locally but fails in Github actions
What happened:
Check out https://github.com/gleitz/howdoi/pull/433/checks?check_run_id=3861232824
The pylint tests fail in Github actions but pass locally (with the same version of pylint).
Locally:
» python setup.py lint
running lint
Running Flake8...
No lint errors found by Flake8
Running Pylint...
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
No lint errors found by Pylint
» pylint --version
pylint 2.11.1
astroid 2.8.0
Python 3.9.7 (default, Sep 20 2021, 08:30:41)
[Clang 12.0.0 (clang-1200.0.32.29)]
The pre-commit is configured to use pylint 2.8.2 which does not give error but pylint 2.11.1 gives the error. You can try it by running pylint howdoi --rcfile=.pylintrc.
Can you check the output of which pylint to see if it from your virtual environment or the global one?
I think we should do three things:
- Unify the version of Pylint (2.11.1) (in
requirements/dev.txt) - Make sure that all pylint command use
pylint howdoi *.py --rcfile=.pylintrc(insetup.pyand.pre-commit-config.yamland.github/workflows/python-non-master.ymland.github/workflows/python.yml) - Pin the version of pylint used by the github action (
.github/workflows/python-non-master.ymland.github/workflows/python.yml)
@V2dha
These are import errors given by Pylint (2.11.1) upon running pylint howdoi *.py --rcfile=.pylintrc
and upon running python3 setup.py lint it only checks the howdoi directory
Development Environment
It's strange that it's mostly import errors - it's almost as if Pylint is not using the virtual environment or something like that.
It's strange that it's mostly import errors - it's almost as if Pylint is not using the virtual environment or something like that.
Upon checking which pylint in the development environment, it is not considering the virtual environment on my system.
Two options here - we can uninstall pylint globally or use the virtual environment's python to run pylint.
Let's try the latter first.
For me, I can find my local python with which python
» which python
/Users/gleitz/.virtualenvs/howdoi/bin/python
Then I can run pylint using this local version of python
» python -m pylint howdoi *.py --rcfile=.pylintrc
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
This should avoid the import-errors.