Tox:针对 flake8 和 pylint 等工具的每个平台配置
Tox: per-platform configuration for tools like flake8 and pylint
我在 linux 和 windows 环境中都为 ci 配置了 tox.ini,类似于:
[tox]
envlist =
{py3,py27}-{test,lint}-{linux,windows}
flake8
check-package
skip_missing_interpreters = true
isolated_build = True
distdir = dist
[testenv]
platform =
linux: linux
windows: win
# Reuse py3 and py27 envs for pylint
envdir =
py3: {toxworkdir}/py3
py27: {toxworkdir}/py27
!py3-!py27: {toxworkdir}/{envname}
deps =
py27: setuptools < 45.0.0
# test extras must include pytest and pylint
extras = test
commands =
test: python -m pytest -c {toxinidir}/pytest.ini --junitxml=test-reports/pytest.{envname}.xml {posargs}
lint: python -m pylint --rcfile=tox.ini src/displaylink {posargs}
[testenv:flake8]
basepython = python3
skip_install = true
deps = flake8
commands = flake8 src tests
[tool:pylint]
disable = missing-docstring,
R,
C,
line-too-long
output-format = parseable
reports = no
extension-pkg-whitelist = win32api, win32gui
[flake8]
ignore = E501, E722, W503
per-file-ignores =
# imported but unused
__init__.py: F401
max-complexity = 10
问题是如何为工具(flake 和 pylint)添加每个平台的配置?我需要从 flake8 中排除 files/dirs 并且 pylint 根据 os 运行,即我有 windows 子目录,其中的文件不会在 linux 上通过 linting,副相反
编辑:
我在 linux:
上遇到的 pylint 错误示例
py3-lint-linux run-test: commands[0] | python -m pylint --rcfile=tox.ini src/displaylink
************* Module displaylink.qa.windows.registry
registry.py:4: [E0401(import-error), ] Unable to import 'win32con'
registry.py:74: [E0602(undefined-variable), reg_value_exists] Undefined variable 'WindowsError'
registry.py:82: [E0602(undefined-variable), reg_key_exists] Undefined variable 'WindowsError'
也许我遗漏了您要求的某些部分,但是 运行 flake8
平台特定似乎很简单:
[testenv]
platform =
linux: linux
windows: win
[testenv:flake8]
deps = flake8
commands =
linux: flake8 <linux specific directories>
windows: flake8 <windows specific directories>
我在 linux 和 windows 环境中都为 ci 配置了 tox.ini,类似于:
[tox]
envlist =
{py3,py27}-{test,lint}-{linux,windows}
flake8
check-package
skip_missing_interpreters = true
isolated_build = True
distdir = dist
[testenv]
platform =
linux: linux
windows: win
# Reuse py3 and py27 envs for pylint
envdir =
py3: {toxworkdir}/py3
py27: {toxworkdir}/py27
!py3-!py27: {toxworkdir}/{envname}
deps =
py27: setuptools < 45.0.0
# test extras must include pytest and pylint
extras = test
commands =
test: python -m pytest -c {toxinidir}/pytest.ini --junitxml=test-reports/pytest.{envname}.xml {posargs}
lint: python -m pylint --rcfile=tox.ini src/displaylink {posargs}
[testenv:flake8]
basepython = python3
skip_install = true
deps = flake8
commands = flake8 src tests
[tool:pylint]
disable = missing-docstring,
R,
C,
line-too-long
output-format = parseable
reports = no
extension-pkg-whitelist = win32api, win32gui
[flake8]
ignore = E501, E722, W503
per-file-ignores =
# imported but unused
__init__.py: F401
max-complexity = 10
问题是如何为工具(flake 和 pylint)添加每个平台的配置?我需要从 flake8 中排除 files/dirs 并且 pylint 根据 os 运行,即我有 windows 子目录,其中的文件不会在 linux 上通过 linting,副相反
编辑:
我在 linux:
上遇到的 pylint 错误示例py3-lint-linux run-test: commands[0] | python -m pylint --rcfile=tox.ini src/displaylink
************* Module displaylink.qa.windows.registry
registry.py:4: [E0401(import-error), ] Unable to import 'win32con'
registry.py:74: [E0602(undefined-variable), reg_value_exists] Undefined variable 'WindowsError'
registry.py:82: [E0602(undefined-variable), reg_key_exists] Undefined variable 'WindowsError'
也许我遗漏了您要求的某些部分,但是 运行 flake8
平台特定似乎很简单:
[testenv]
platform =
linux: linux
windows: win
[testenv:flake8]
deps = flake8
commands =
linux: flake8 <linux specific directories>
windows: flake8 <windows specific directories>