问题
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
then it should pick up that config.
I'm using autopep8 via the pre-commit hook, here: https://github.com/pre-commit/mirrors-autopep8
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.
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?
回答1:
I found a workaround: excluding files on a pre-commit level, rather than via autopep8.
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
来源:https://stackoverflow.com/questions/55172676/autopep8-doesnt-seem-to-be-finding-config-file