为什么 flake8 在本地和在 tox 中对同一命令给出不同的结果?
Why does flake8 give different results for the same command locally and within tox?
我有一个 Python 项目,我使用 flake8
来检查我的代码。
在本地,flake8
正确地提出了一个警告:
$ flake8 scripts src tests --ignore=W503,E501
src/projectname/workers/utils.py:22:20: W291 trailing whitespace
但是,tox
中的相同命令不会引发任何警告:
$ tox -e flake8
得到以下输出:
flake8 develop-inst-noop: /home/username/Projects/projectname
flake8 installed: alembic==0.9.8, ..., zipp==0.5.2
flake8 runtests: PYTHONHASHSEED='2190899390'
flake8 runtests: commands[0] | flake8 scripts src tests --ignore=W503,E501
________________________________ summary _________________________________
flake8: commands succeeded
congratulations :)
这是我的 tox.ini
文件的内容:
[tox]
envlist = flake8,py36
[testenv]
changedir = {toxworkdir}/{envname}
usedevelop = True
install_command = pip install {opts} {packages}
deps =
py36: pytest-cov
py36: pytest
flake8: flake8
setenv =
COVERAGE_FILE = {toxinidir}/.coverage.{envname}
commands =
py36: pytest {toxinidir}/tests --cov=projectname {posargs}
flake8: flake8 scripts src tests --ignore=W503,E501
; E501: line too long
; W503: line break before binary operator
我检查过,在两个实验中,我都有 flake8==3.7.9
在这种情况下,为什么 flake8
和 tox
没有 return 任何错误代码?
您的 tox.ini
有:
changedir = {toxworkdir}/{envname}
这意味着当你 运行 flake8
在 tox 中时,它是 linting(不存在的).tox/flake8/scripts
/ .tox/flake8/src
/ .tox/flake8/tests
所以你没有看到错误(3.7.x 行为是默默地忽略不存在的东西)
请注意,在 flake8 3.8(撰写本文时,尚未发布)中,这将再次成为错误 (E902):
$ flake8 does-not-exist
does-not-exist:0:1: E902 FileNotFoundError: [Errno 2] No such file or directory: 'does-not-exist'
免责声明:我是 flake8 的当前维护者,也是 tox 的维护者之一
我有一个 Python 项目,我使用 flake8
来检查我的代码。
在本地,flake8
正确地提出了一个警告:
$ flake8 scripts src tests --ignore=W503,E501
src/projectname/workers/utils.py:22:20: W291 trailing whitespace
但是,tox
中的相同命令不会引发任何警告:
$ tox -e flake8
得到以下输出:
flake8 develop-inst-noop: /home/username/Projects/projectname
flake8 installed: alembic==0.9.8, ..., zipp==0.5.2
flake8 runtests: PYTHONHASHSEED='2190899390'
flake8 runtests: commands[0] | flake8 scripts src tests --ignore=W503,E501
________________________________ summary _________________________________
flake8: commands succeeded
congratulations :)
这是我的 tox.ini
文件的内容:
[tox]
envlist = flake8,py36
[testenv]
changedir = {toxworkdir}/{envname}
usedevelop = True
install_command = pip install {opts} {packages}
deps =
py36: pytest-cov
py36: pytest
flake8: flake8
setenv =
COVERAGE_FILE = {toxinidir}/.coverage.{envname}
commands =
py36: pytest {toxinidir}/tests --cov=projectname {posargs}
flake8: flake8 scripts src tests --ignore=W503,E501
; E501: line too long
; W503: line break before binary operator
我检查过,在两个实验中,我都有 flake8==3.7.9
在这种情况下,为什么 flake8
和 tox
没有 return 任何错误代码?
您的 tox.ini
有:
changedir = {toxworkdir}/{envname}
这意味着当你 运行 flake8
在 tox 中时,它是 linting(不存在的).tox/flake8/scripts
/ .tox/flake8/src
/ .tox/flake8/tests
所以你没有看到错误(3.7.x 行为是默默地忽略不存在的东西)
请注意,在 flake8 3.8(撰写本文时,尚未发布)中,这将再次成为错误 (E902):
$ flake8 does-not-exist
does-not-exist:0:1: E902 FileNotFoundError: [Errno 2] No such file or directory: 'does-not-exist'
免责声明:我是 flake8 的当前维护者,也是 tox 的维护者之一