我在 GitHub 上有一個存盤庫,其中包含用于 github 操作配置的 my.yaml 檔案,如下所示:
name: flake8 Lint
on: [push, pull_request]
jobs:
flake8-lint:
runs-on: ubuntu-latest
name: Lint
steps:
- name: Check out source repository
uses: actions/checkout@v2
- name: Set up Python environment
uses: actions/setup-python@v1
with:
python-version: "3.8"
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
max-line-length: "100"
path: "app"
這個檔案作業得非常好并且通過提交,但是,我最近在我的應用程式檔案夾中添加了更多代碼(燒瓶應用程式代碼),現在它失敗并給出如下所示的錯誤:
Run py-actions/flake8@v2
[*] Installing flake8 package @ latest...
/opt/hostedtoolcache/Python/3.8.12/x64/bin/python -m pip install --upgrade flake8
Collecting flake8
Downloading flake8-4.0.1-py2.py3-none-any.whl (64 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.1/64.1 KB 14.6 MB/s eta 0:00:00
Collecting pyflakes<2.5.0,>=2.4.0
Downloading pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.7/69.7 KB 18.3 MB/s eta 0:00:00
Collecting mccabe<0.7.0,>=0.6.0
Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pycodestyle<2.9.0,>=2.8.0
Downloading pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.1/42.1 KB 10.8 MB/s eta 0:00:00
Installing collected packages: mccabe, pyflakes, pycodestyle, flake8
Successfully installed flake8-4.0.1 mccabe-0.6.1 pycodestyle-2.8.0 pyflakes-2.4.0
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the '/opt/hostedtoolcache/Python/3.8.12/x64/bin/python -m pip install --upgrade pip' command.
[*] Installed flake8 package version:
/opt/hostedtoolcache/Python/3.8.12/x64/bin/flake8 --version
4.0.1 (mccabe: 0.6.1, pycodestyle: 2.8.0, pyflakes: 2.4.0) CPython 3.8.12 on
Linux
/opt/hostedtoolcache/Python/3.8.12/x64/bin/flake8 --max-line-length 100 app
app/__init__.py:5:1: W293 blank line contains whitespace
app/__init__.py:6:1: E302 expected 2 blank lines, found 1
app/__init__.py:6:28: E251 unexpected spaces around keyword / parameter equals
app/__init__.py:6:30: E251 unexpected spaces around keyword / parameter equals
app/__init__.py:9:1: W293 blank line contains whitespace
app/__init__.py:12:1: W293 blank line contains whitespace
app/__init__.py:15:1: W293 blank line contains whitespace
app/config.py:7:1: E302 expected 2 blank lines, found 1
app/main/routes.py:1:1: F401 'flask.Flask' imported but unused
app/main/routes.py:1:1: F401 'flask.url_for' imported but unused
app/main/routes.py:1:1: F401 'flask.redirect' imported but unused
app/main/routes.py:1:1: F401 'flask.request' imported but unused
app/main/routes.py:4:1: W293 blank line contains whitespace
app/main/routes.py:6:1: E302 expected 2 blank lines, found 1
app/main/routes.py:6:32: E231 missing whitespace after ','
app/main/routes.py:8:1: W293 blank line contains whitespace
app/main/routes.py:9:41: W292 no newline at end of file
Error: The process '/opt/hostedtoolcache/Python/3.8.12/x64/bin/flake8' failed with exit code 1
我的應用程式檔案夾中有不是 .py 的檔案,這可能是導致 github 操作 flake8 測驗失敗的問題,如果是這樣,我該如何忽略其他檔案?
uj5u.com熱心網友回復:
您的問題似乎是您的代碼未通過PEP8,如果您不通過, Flake8 檢查將失敗(這就是重點)。請注意,Flake8 檢查不會重新格式化檔案,它只會告訴您它們是錯誤的!錯誤日志將告訴您各個錯誤代碼(例如W293 blank line contains whitespace)
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/443661.html
標籤:Python github 持续集成 github-动作 片状8
下一篇:為什么會產生一個空的合并提交
