autopep8似乎没有找到配置文件?

问题描述 投票:0回答:1

根据autopep8的文档(这里:https://github.com/hhatto/autopep8#configuration),如果我在我的git repo的根目录中放置一个名为“setup.cfg”的文件,就像

[pycodestyle]
ignore = D203,E501,E201,E202,E203,E211,E261,E265,W503
exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,__init__.py,*_gui.py
max-complexity = 25
max-line-length = 160
statistics = True

然后它应该拿起那个配置。

我通过预提交钩子使用autopep8,这里:https://github.com/pre-commit/mirrors-autopep8

我能说的最好,它没有找到setup.cfg。我在同一目录中也有一个用于flake8的.flake8文件 - flake8的预提交钩子没有问题。

我发现虽然autopep8只是在修改过的文件上运行(好),但它不排除* _gui.py

这是一个错误吗?难道我做错了什么?

python git pep8 pre-commit autopep8
1个回答
0
投票

我找到了一种解决方法:在预提交级别上排除文件,而不是通过autopep8。

在我们的.pre-commit-config.yaml文件中:

-   repo: https://github.com/pre-commit/mirrors-autopep8
    rev: '4b4928307f1e6e8c9e02570ef705364f47ddb6dc'  # Use the sha / tag you want to point at
    hooks:
    -   id: autopep8
        exclude: (?i)^.*gui.py

现在它正确排除了这些文件

© www.soinside.com 2019 - 2024. All rights reserved.