Python 需要路径查找方面的帮助吗
我为我的回购做了一个GitHub操作。它检查Pull请求中的所有Python 需要路径查找方面的帮助吗,python,python-3.x,github,path,yaml,Python,Python 3.x,Github,Path,Yaml,我为我的回购做了一个GitHub操作。它检查Pull请求中的所有.py文件,然后对其运行pylint测试 我设计了我的PyLint代码,这样它就可以在不同的Python文件上工作,无论是失败还是通过代码,阈值都是不同的 我对yml开发有点陌生,不知道如何解决下面提到的错误 Run python pyLint.py --path 'Python/smurf.py' --threshold 10 python pyLint.py --path 'Python/smurf.py' --thresh
.py
文件,然后对其运行pylint
测试
我设计了我的PyLint代码,这样它就可以在不同的Python文件上工作,无论是失败还是通过代码,阈值都是不同的
我对yml
开发有点陌生,不知道如何解决下面提到的错误
Run python pyLint.py --path 'Python/smurf.py' --threshold 10
python pyLint.py --path 'Python/smurf.py' --threshold 10
shell: /bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.8.6/x64
INFO:root:PyLint Starting | Path: ['Python/smurf.py'] | Threshold: 10.0
Traceback (most recent call last):
File "pyLint.py", line 41, in <module>
final_score = results.linter.stats['global_note']
KeyError: 'global_note'
************* Module ['Python/smurf.py']
['Python/smurf.py']:1:0: F0001: No module named ['Python/smurf.py'] (fatal)
Error: Process completed with exit code 1.
.yml
文件-
# .github/workflows/lint.yaml
name: PyLint Runner
on: [pull_request]
# pull_request:
# branches:
# - master
# - another
# - again
# paths:
# - 'Python/**.py'
# - '**/**.py'
# - '!.github/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Requirements
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Paths Changes Filter
uses: dorny/paths-filter@v2.5.1
id: changes
with:
filters: |
Python: path
- '**/**.py'
- name: Detect Files
uses: dorny/paths-filter@v2
id: filter
with:
# Enable listing of files matching each filter.
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
# Paths will be escaped and space-delimited.
# Output is usable as command line argument list in linux shell
list-files: shell
# In this example changed files will be checked by linter.
# It doesn't make sense to lint deleted files.
# Therefore we specify we are only interested in added or modified files.
filters: |
python:
- added|modified: '**.py'
- name: PyLint Python
if: ${{ steps.filter.outputs.python == 'true' }}
run: python pyLint.py --path ${{ steps.filter.outputs.python_files }} --threshold 10
#- name: Run lint check
# env:
# FILES: '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}'
# run: |
# echo "The Following files were changed or created:"
# echo $FILES
# for FILE in $FILES; do python pyLint.py --path FILE --threshold 10; done
这里的错误很明显(我认为),我的.yml
文件以Python/smurf.py
格式返回文件路径。我的pylint.py
对此不满意。有人能指导我如何处理这件事吗
# .github/workflows/lint.yaml
name: PyLint Runner
on: [pull_request]
# pull_request:
# branches:
# - master
# - another
# - again
# paths:
# - 'Python/**.py'
# - '**/**.py'
# - '!.github/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install Requirements
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Paths Changes Filter
uses: dorny/paths-filter@v2.5.1
id: changes
with:
filters: |
Python: path
- '**/**.py'
- name: Detect Files
uses: dorny/paths-filter@v2
id: filter
with:
# Enable listing of files matching each filter.
# Paths to files will be available in `${FILTER_NAME}_files` output variable.
# Paths will be escaped and space-delimited.
# Output is usable as command line argument list in linux shell
list-files: shell
# In this example changed files will be checked by linter.
# It doesn't make sense to lint deleted files.
# Therefore we specify we are only interested in added or modified files.
filters: |
python:
- added|modified: '**.py'
- name: PyLint Python
if: ${{ steps.filter.outputs.python == 'true' }}
run: python pyLint.py --path ${{ steps.filter.outputs.python_files }} --threshold 10
#- name: Run lint check
# env:
# FILES: '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}'
# run: |
# echo "The Following files were changed or created:"
# echo $FILES
# for FILE in $FILES; do python pyLint.py --path FILE --threshold 10; done