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

Why doesn't #noqa work for lambda statement ? #527

Open qiulang opened 4 years ago

qiulang commented 4 years ago

Python Code

_trie = lambda: defaultdict(_trie) # noqa

Command Line

autopep8 --in-place xxx
# The line was changed to 
def _trie(): return defaultdict(_trie)

Your Environment

hhatto commented 4 years ago

Currently, noqa follows the behavior defined in pycodestyle.

Only error codes marked with a ^ in the following table will have NOQA enabled: http://pycodestyle.pycqa.org/en/latest/intro.html#error-codes

It is preferable to specify --ignore=E731 instead.

Borda commented 3 years ago

I have added the following to pyproject.toml and use it with pre-commit

[tool.autopep8]
ignore = ["E731"]

but still, the lambda is replaced, it that a known issue? related to https://github.com/hhatto/autopep8/issues/509#issuecomment-552066238