E701: Move one-liner classes from E701 to E704?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in the repository's one-file Python implementation at compound_statements and inspect how STARTSWITH_DEF_REGEX selects E704 cases. Confirm the current diagnostics for one-line classes and functions, then establish the expected E701/E704 messages and ignored-by-default behavior. Done means the agreed class handling and diagnostic wording are covered by the project's checks.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100