-
Notifications
You must be signed in to change notification settings - Fork 750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
E701, E302: allowing one-liners for classes #231
Comments
I've written a draft to show you my idea. |
How about authorize |
I see this hasn't had activity in a long time, but I really want this. |
Where is the allowance for dummy one liners? The closest I see is in Other Recommendations:
If that is the only reference, I'm leaning towards closing this and having this tool take the stance that these will always be an error. |
Under Blank Lines I see:
This definitely means that class CustomException(Exception):
pass
class AnotherException(Exception):
pass
class YetAnotherException(Exception):
pass should be allowed, and I would argue that in the same spirit, class CustomException(Exception): pass
class AnotherException(Exception): pass
class YetAnotherException(Exception): pass should probably be allowed. |
I was just about to post this very bug report. Related cases that should also, IMNSHO, be exempt:
and
|
I'm currently writing a program that's producing a bunch of files with empty stub functions for tools to use, since the real definitions are injected from a host program, and I was hoping I could have them lint cleanly. Unfortunately, this still blocks the nice-looking stubs. |
for what it's worth, this has now been relaxed for functions (and probably could also be relaxed for classes as well) def f(): pass
def g(): pass
def h(): pass $ ./venv/bin/pycodestyle --version
2.5.0
$ ./venv/bin/pycodestyle t.py
$ |
PEP8 allows you to type a bunch of dummy one-liners like this:
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.
The text was updated successfully, but these errors were encountered: