本文介绍了autopep8似乎没有找到配置文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

According to autopep8's documentation (here: https://github.com/hhatto/autopep8#configuration ), if I place a file called "setup.cfg" in the root of my git repo, with something like

[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

I'm using autopep8 via the pre-commit hook, here: https://github.com/pre-commit/mirrors-autopep8

据我所知,它没有找到setup.cfg.我在同一目录中也有一个用于flake8的.flake8文件-flake8的pre-commit钩子可以轻松地将其拾起.

Best I can tell, it's not finding the setup.cfg. I also have a .flake8 file used for flake8 in the same directory - flake8's pre-commit hook has no trouble picking that up.

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

What I'm finding is that while autopep8 is only being run on modified files (good), it is NOT excluding *_gui.py

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

Is this a bug? Am I doing something wrong?

推荐答案

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

I found a workaround: excluding files on a pre-commit level, rather than via autopep8.

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

in our .pre-commit-config.yaml file:

-   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

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

now it excludes those files properly

这篇关于autopep8似乎没有找到配置文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-11 14:11