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

autopep8 doesn't seem to be finding config file?

根据 autopep8 的文档(此处:https://github.com/hhatto/autopep8#configuration),如果我将一个名为 "setup.cfg" 的文件放在我的 git 存储库的根目录中,其中包含

[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

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

我找到了一个解决方法:排除预提交级别的文件,而不是通过 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

现在它正确地排除了那些文件