Issue
The following GitHub Pylint starter-workflow fails with lots of pylint
F0001 errors.
This is the href="https://github.com/actions/starter-workflows/blob/9482241d4bee946d31163d5b268d6fb813ca6609/ci/pylint.yml" rel="nofollow noreferrer">github-workflow source code:
name: Pylint
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pylint `ls -R|grep .py$|xargs`
These are the errors that the workflow outputs:
Run pylint $(ls -R | grep '.py$' | xargs)
************* Module __init__.py
__init__.py:1:0: F0001: No module named __init__.py (fatal)
__init__.py:1:0: F0001: No module named __init__.py (fatal)
************* Module pet.py
pet.py:1:0: F0001: No module named pet.py (fatal)
************* Module Authorization.py
Authorization.py:1:0: F0001: No module named Authorization.py (fatal)
************* Module Http.py
Http.py:1:0: F0001: No module named Http.py (fatal)
__init__.py:1:0: F0001: No module named __init__.py (fatal)
...
Error: Process completed with exit code 17.
Why can't pylint
find these modules?
Solution
Cause of the failure
The GitHub action workflow contains a bug over here:
| run
pylint `ls -R|grep .py$|xargs`
The solution
The solution is to replace:
pylint `ls -R|grep .py$|xargs`
By:
pylint $(find . -name "*.py" | xargs)
Explanation of the bug
ls -R
returns the files in the current directory with the following format:
./dir1:
__init__.py file1.py
./dir1/dir2
__init__.py file2.py
If you filter the output of ls -R
with grep .py$
, you'll lose the path to the *.py
files. pylint
cannot find these files.
As a result, pylint
fails with F0001 errors:
$ pylint --help-msg=F0001
:fatal (F0001):
Used when an error occurred preventing the analysis of a module (unable to
find it for instance). This message belongs to the master checker.
Answered By - melvio Answer Checked By - Mary Flores (WPSolving Volunteer)