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
a ‘pass’ statement in an intentionally empty function with a docstring is not useless #73
Comments
I just came across this tool and was very exited. But this is a showstopper. Can you make it configurable to remove 'useless' |
This also happens if you use methods decorated with |
Sometimes people use ellipsis Still, I actually prefer using ellipsis in these cases, as it stands out more clear that method/function doesn't have implementation, and autoflake doesn't seem to complain about it either. |
|
Good explanation, thanks! |
Will this be fixed? |
not all
pass
statements occurring in places where they are not technically required are useless.consider for instance a command line app written using the popular
click
library, featuring some subcommands (see docs). for the sake of argument, consider a hypotheticalgit
-like application supporting a command likegit remote add
, which would look like this:now, let's add docstrings, which in the case of
click
, also appear in--help
output:technically, the presence of a docstring means the
pass
is not needed to make it valid python. but thepass
shows the intent to the reader. without it i would immediately wonder if someone forget to write some code, or if some git merge went wrong. in this specific example,click
actually supports shared code in functions decorated withclick.group()
. the presence ofpass
signals that this function does not need that, and is intended as an empty body.so, in short: not all
pass
statements that are strictly technically unnecessary are to be considered ‘useless’.my suggestion would be to treat the ‘function body, with only a docstring and a pass statement’ as an extra special case, and always leave the
pass
statements in place.The text was updated successfully, but these errors were encountered: