pycodestyle icon indicating copy to clipboard operation
pycodestyle copied to clipboard

E701: Move one-liner classes from E701 to E704?

Open anntzer opened this issue 6 years ago • 0 comments

Currently, one-liner classes (class Foo: pass or for example more realistically class T(Enum): a, b, c = range(3)) trigger E701 ("multiple statements on one line (colon)"). I would suggest moving them to E704 ("multiple statements on one line (def)") (changing the message to use "def/class") as I think a one-liner class is closer in spirit to a one-liner function than to constructs like if cond: ... or for ... in ...: .... This would also make this check ignored by default.

I think the implementation is simply a matter of changing the use of STARTSWITH_DEF_REGEX in compound_statements to, well also match class statements; would be happy to provide a PR if the change is agreed upon.

anntzer avatar Apr 09 '19 16:04 anntzer