根据autopep8的文档(这里:https://github.com/hhatto/autopep8#configuration ),如果我在我的git代码库的根目录中放置一个名为"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的pre-commit钩子可以毫不费力地获得它。
我发现,虽然autopep8只在修改过的文件上运行(很好),但它并不排除*_gui.py
这是一个bug吗?我做错了什么吗?
发布于 2019-03-22 02:58:46
我找到了一个解决方法:在预提交级别排除文件,而不是通过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现在,它正确地排除了这些文件
https://stackoverflow.com/questions/55172676
复制相似问题