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

Create diff for a specific pep8 issue #227

Open AbdealiLoKo opened 8 years ago

AbdealiLoKo commented 8 years ago

I'm trying to use autopep8 to automate a few things. This is my workflow:

I notice with --select I can choose which errors autopep8 fixes, how do I specify a specific issue (I guess this is characterized by line, column, issue code) to fix ?

Could you help me on how to do this ?

Example: I have a file with the line print( sys.path, ( 2)) This raises

test.py:1:7: E201 whitespace after '('
test.py:1:19: E201 whitespace after '('

So, I run autopep8 test.py --select=E201 --range 1 1 --diff but this fixes both errors.

myint commented 8 years ago

I suppose that might work. I have no idea if all of autopep8's fixers respect columns though. There may or may not be fixers that fix the whole line.

By the way, I'm not sure how the title of this issue "Show error along with creating diff" relates to the contents of the issue.

jayvdb commented 6 years ago

Note that in https://github.com/hhatto/autopep8/commit/73837064845802307e7d31e29e3ebc34626dd00f --range was given new name --line-range to be more correct. I guess --range is implicitly deprecated.