【问题标题】:GitHub Actions: pylint fails with F0001: No module named __init__.py (fatal)GitHub Actions:pylint 失败并显示 F0001:没有名为 __init__.py 的模块(致命)
【发布时间】:2021-10-21 21:50:14
【问题描述】:

以下 GitHub Pylint starter-workflow 失败,出现大量 pylint F0001 错误。

这是 github-workflow源码:

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`

这些是工作流输出的错误:

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.

为什么pylint 找不到这些模块?

【问题讨论】:

    标签: python-3.x github grep github-actions pylint


    【解决方案1】:

    失败原因

    GitHub 操作工作流程在此处包含一个错误:

     | run  
        pylint `ls -R|grep .py$|xargs`
    

    解决办法

    解决办法是替换:

        pylint `ls -R|grep .py$|xargs`
    

    作者:

        pylint $(find . -name "*.py" | xargs)
    

    错误说明

    ls -R返回当前目录下的文件,格式如下:

    ./dir1:
    __init__.py file1.py
    
    ./dir1/dir2
    __init__.py file2.py
    

    如果您使用grep .py$ 过滤ls -R 的输出,您将丢失*.py 文件的路径。 pylint 找不到这些文件。

    因此,pylint 失败并出现 F0001 错误:

    $ 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.
    

    【讨论】:

    • 本期目前开放于:github.com/actions/starter-workflows/issues/636>
    猜你喜欢
    • 1970-01-01
    • 2023-04-05
    • 2021-08-17
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    • 1970-01-01
    • 1970-01-01
    • 2015-01-20
    相关资源
    最近更新 更多