Python 3.6 预提交:使用python 3.6.8运行flake8

Python 3.6 预提交:使用python 3.6.8运行flake8,python-3.6,flake8,pre-commit,pre-commit.com,Python 3.6,Flake8,Pre Commit,Pre Commit.com,我在我的系统上安装了Pyton 3.6.8 python3 --version //-> Python 3.6.8 python3.6 --version //-> Python 3.6.8 我的pre-commit-config.yaml是: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.4.0 - repo: https://gitlab.com/pycqa/flake8

我在我的系统上安装了Pyton 3.6.8

python3 --version   //-> Python 3.6.8
python3.6 --version //-> Python 3.6.8
我的pre-commit-config.yaml是:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
-   repo: https://gitlab.com/pycqa/flake8
rev: 3.7.9
hooks:
- id: flake8
  language_version: python3.6
我为我的项目安装了预提交钩子。 每次我想提交对git的一些更改时,预提交都会运行,并出现flake8错误:

TYP005 NamedTuple does not support defaults in 3.6.0
这对于Python3.6.0是正确的,因为Python3.6.1+引入并允许此功能。

如何将flake8配置为与Python 3.6.8一起运行

编辑 当我运行flake8 file.rb时,没有收到错误消息TYP005

python3 -m pip install flake
flake --version //-> 3.7.9 (the same version as in the pre-commit script file)

免责声明:我是两个相关工具(预提交、flake8键入导入)的作者,另一个工具(flake8)的维护者


TYP005代码来自

有两个选项可用于将支持的最低版本指示为
flake8输入导入
,第一个是命令行参数/flake8设置:

--min-python-version 3.6.1
或者在您的flake8配置中

[flake8]
min_python_version = 3.6.1

如果要分发库,可以使用--this在
setup.cfg

[options]
python_requires >= 3.6.1

顺便说一句,我相信您的问题中缺少一些信息,如果您的预提交配置中没有
其他依赖项
flake8
将单独安装,并且无法访问插件,例如
flake8输入导入
——我猜您实际拥有的配置类似于:


-回购:https://gitlab.com/pycqa/flake8
修订:3.7.9
挂钩:
-id:8
其他依赖项:[8键入导入==1.9.0]
当谈到上面的命令行参数时,您可以在这里将它们指定为
args
(尽管我个人更喜欢配置文件方法)

-id:8
args:[--min python版本,'3.6.1']
其他依赖项:[8键入导入==1.9.0]

免责声明:我是两个相关工具(预提交、flake8键入导入)的作者,另一个工具(flake8)的维护者


TYP005代码来自

有两个选项可用于将支持的最低版本指示为
flake8输入导入
,第一个是命令行参数/flake8设置:

--min-python-version 3.6.1
或者在您的flake8配置中

[flake8]
min_python_version = 3.6.1

如果要分发库,可以使用--this在
setup.cfg

[options]
python_requires >= 3.6.1

顺便说一句,我相信您的问题中缺少一些信息,如果您的预提交配置中没有
其他依赖项
flake8
将单独安装,并且无法访问插件,例如
flake8输入导入
——我猜您实际拥有的配置类似于:


-回购:https://gitlab.com/pycqa/flake8
修订:3.7.9
挂钩:
-id:8
其他依赖项:[8键入导入==1.9.0]
当谈到上面的命令行参数时,您可以在这里将它们指定为
args
(尽管我个人更喜欢配置文件方法)

-id:8
args:[--min python版本,'3.6.1']
其他依赖项:[8键入导入==1.9.0]

语言版本:python3.6.8
?或者这是一个可执行文件?我猜你在用。你还有其他的flake8配置吗?如果不是通过预提交运行它会发生什么?是的,我使用pre-commit.com。如果我使用python3.6.8,我仍然会得到相同的错误。我没有更多的flake8配置文件。如果直接运行flake8呢?也许您应该使用其他配置。当我运行flake8 file.rb时,我没有收到此错误消息。安装人;python3-mpip8安装。此外,第8版也是3.7.9版,请将此信息输入问题。
语言\u版本:python3.6.8
?或者这是一个可执行文件?我猜你在用。你还有其他的flake8配置吗?如果不是通过预提交运行它会发生什么?是的,我使用pre-commit.com。如果我使用python3.6.8,我仍然会得到相同的错误。我没有更多的flake8配置文件。如果直接运行flake8呢?也许您应该使用其他配置。当我运行flake8 file.rb时,我没有收到此错误消息。安装人;python3-mpip8安装。此外,第8版也是3.7.9版,请将此信息输入问题中。