根据 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
然后它应该选择该配置。
我通过预提交 Hook 使用 autopep8,此处:https://github.com/pre-commit/mirrors-autopep8
据我所知,它没有找到 setup.cfg。我在同一目录中还有一个用于 flake8 的 .flake8 文件 - flake8 的预提交 Hook 可以轻松拾取该文件。
我发现虽然 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
现在它可以正确排除这些文件
关于python - autopep8 似乎没有找到配置文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55172676/