运行 python 2.7 和 3.7 的 pylint,在 Docker 图像上的预提交挂钩中
Run pylint for both python 2.7 and 3.7, in pre-commit hook on Docker image
我正在尝试将 CircleCI 用于 运行 预提交挂钩,运行s pylint 用于 Python 2.7 和 3.7。
.circleci/config.yml
运行s 预提交 Python 2 和 Python 3:
jobs:
lint-py2:
docker:
- image: python:2.7.14
steps:
{snip}
- run: pre-commit run --all-files
{snip}
lint-py3:
docker:
- image: python:3.7.3
steps:
{snip}
- run: pre-commit run --all-files
{snip}
预提交,除其他外,运行s pylint:
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1 # Which version here?
hooks:
- id: pylint
这里的问题是 there is no version of pylint that is compatible with both Python 2.7 and 3.7:Python 2.7 需要 pylint 1.x 和 Python 3.7 需要 pylint 2.x.
如何使用不同版本的 pylint 使 Circle CI 运行 都成为 linting 作业?
我正在考虑几个选项:
- 在预提交配置中添加 pylint 两次(使用不同的别名),disable 在作业定义中添加一个或另一个
- 似乎预提交尝试在 查看
SKIP
变量之前安装依赖项 ,因此 Python 2.7 运行 尝试无论如何都要安装 pylint 2,并且 ERROR: Could not find a version that satisfies the requirement pylint==2.3.1 (from pre-commit-dummy-package==0.0.0)
出现错误
- 使用 Docker 图像,在挂钩级别同时具有 Python 版本和 set the python version
- 这需要构建我自己的 Docker 图像
- 在其中一个 linting 作业中跳过 pylint
- 放弃 2.7 或 3.7 支持
最简单的选择可能是同时安装 python2 和 python3,尽管可以使用多个配置文件来完成您想要的:
另一种选择是在 CI 期间仅 运行 其中之一,方法是利用 --config
选项
有了这个,您将拥有默认的 .pre-commit-config.yaml
和一个特殊的 .pre-commit-config-py27.yaml
,其中包括 python2.7 pylint 而不是 python3 pylint
在 CI 中,您将为 python2.7 调用 pre-commit run --config .pre-commit-config-py27.yaml --all-files --show-diff-on-failure
,为非 py27 运行[=16= 调用正常的 pre-commit run --all-files --show-diff-on-failure
]
我正在尝试将 CircleCI 用于 运行 预提交挂钩,运行s pylint 用于 Python 2.7 和 3.7。
.circleci/config.yml
运行s 预提交 Python 2 和 Python 3:
jobs:
lint-py2:
docker:
- image: python:2.7.14
steps:
{snip}
- run: pre-commit run --all-files
{snip}
lint-py3:
docker:
- image: python:3.7.3
steps:
{snip}
- run: pre-commit run --all-files
{snip}
预提交,除其他外,运行s pylint:
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1 # Which version here?
hooks:
- id: pylint
这里的问题是 there is no version of pylint that is compatible with both Python 2.7 and 3.7:Python 2.7 需要 pylint 1.x 和 Python 3.7 需要 pylint 2.x.
如何使用不同版本的 pylint 使 Circle CI 运行 都成为 linting 作业?
我正在考虑几个选项:
- 在预提交配置中添加 pylint 两次(使用不同的别名),disable 在作业定义中添加一个或另一个
- 似乎预提交尝试在 查看
SKIP
变量之前安装依赖项 ,因此 Python 2.7 运行 尝试无论如何都要安装 pylint 2,并且ERROR: Could not find a version that satisfies the requirement pylint==2.3.1 (from pre-commit-dummy-package==0.0.0)
出现错误
- 似乎预提交尝试在 查看
- 使用 Docker 图像,在挂钩级别同时具有 Python 版本和 set the python version
- 这需要构建我自己的 Docker 图像
- 在其中一个 linting 作业中跳过 pylint
- 放弃 2.7 或 3.7 支持
最简单的选择可能是同时安装 python2 和 python3,尽管可以使用多个配置文件来完成您想要的:
另一种选择是在 CI 期间仅 运行 其中之一,方法是利用 --config
选项
有了这个,您将拥有默认的 .pre-commit-config.yaml
和一个特殊的 .pre-commit-config-py27.yaml
,其中包括 python2.7 pylint 而不是 python3 pylint
在 CI 中,您将为 python2.7 调用 pre-commit run --config .pre-commit-config-py27.yaml --all-files --show-diff-on-failure
,为非 py27 运行[=16= 调用正常的 pre-commit run --all-files --show-diff-on-failure
]