Skip to content

E701, E302: allowing one-liners for classes #231

Open
@chrismedrela

Description

@chrismedrela

PEP8 allows you to type a bunch of dummy one-liners like this:

class CustomException(Exception): pass
class AnotherException(Exception): pass
class YetAnotherException(Exception): pass

But this code raises E701 (compound statement) and E302 (two lines between classes) errors. I propose to leave compound statements intact if they are a bunch of class/def definitions. This is what I've done in this pull request of autopep8 project: hhatto/autopep8#87, but it wasn't merged since pep8 seems to be a better place for that.

This is not easy to implement since the current framework doesn't allow you to look at the next logical line. This is necessary because you need to look at previous and next line to determine if a definition is alone or inside a bunch of definitions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions