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

Multiple #autopep8: off/on directives in one file do not work #603

Closed JLVarjo closed 2 years ago

JLVarjo commented 3 years ago

See the example below: when there are multiple #autopep8: off/on blocks in a file, they do not seem to be respected anymore. Enclosing both lists within just one such block works correctly.


Python Code

# autopep8: off
myneatlist=[
    ("foo",      1,),
    ("bar",      2,),
    ("foobar",   3,),
]

# autopep8: on
# autopep8: off

myneatlist2=[
    ("foo",      1,),
    ("bar",      2,),
    ("foobar",   3,),
]
# autopep8: on

Configuration

.pep8:

[pycodestyle]
max_line_length = 175
#E302 - Add missing 2 blank lines.
#E305 - Expected 2 blank lines after end of function or class.
#E701 - Put colon-separated compound statement on separate lines.
ignore = E302, E305, E701
hhatto commented 2 years ago

@JLVarjo Thanks for reporting. This problem has been fixed in version 1.6.