hhatto / autopep8

A tool that automatically formats Python code to conform to the PEP 8 style guide.
https://pypi.org/project/autopep8/
MIT License
4.56k stars 290 forks source link

Feature request: per-file-ignore for specific fixes #572

Open zcutlip opened 3 years ago

zcutlip commented 3 years ago

It would be nice if autopep8 supported a per-file-ignores command line/config option similar to flake8's

There are times when I want most of what autopep8 fixes in my editor, but certain files are problematic (e.g., lots of trailing whitespace). So I want to ignore just those fixes on those specific files.

An example config would like like:

[autopep8]
per-file-ignores = 
    problem_file_1.py: W291, W391
    problem_file_2.py: E224

Your Environment

shaperilio commented 2 years ago

It seems autopep8 doesn't support in-line comments in the configuration, either. It's confusing that it's set to share the flake8 section in setup.cfg when it can't parse it the way flake8 does.

Avasam commented 1 year ago

Yes please! A lot of PEP8 standard doesn't fit modern type-stubs best practices, I'd like to disable some rules in *.pyi only.

lucas-labs commented 10 months ago

This would be great. I usually find that there are certain rules that I just don't want to respect for certain files. Especially, for test files.

When writing tests, we usually do things that we wouldn't do in other scenarios. For example, having a long line with a hardocded list of objects to test a function with different inputs. It would be helful to be able to disable rule E501 for test_*.py or conftest.py files, for example.