E701, E302: allowing one-liners for classes
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.2k
- Forks
- 754
- PR merge metrics
- No merged PRs in 30d
Description
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: https://github.com/hhatto/autopep8/pull/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.
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 by reviewing the existing E701 and E302 handling in pycodestyle's single Python file, then compare the linked autopep8 pull request for the proposed behavior. Done means consecutive one-line class or function definitions can remain intact without those errors, while unrelated compound statements and spacing violations are still checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100