Skip to content
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

Add option to keep pass statements #143

Merged
merged 1 commit into from Sep 18, 2022
Merged

Add option to keep pass statements #143

merged 1 commit into from Sep 18, 2022

Conversation

alvarotroya
Copy link
Contributor

@alvarotroya alvarotroya commented Sep 18, 2022

Changes in this PR:

  • Add two flags to customize autoflake's behavior for pass statements:
    - ignore-pass-statements: allows the user to opt out of the removal of useless pass statements if desired.
    - ignore-pass-after-docstring: allows the user to keep pass statements after a docstring (see below for caveat).
  • Add tests for new flags.
  • Update README.

Caveat: since autoflake does not use an AST, deciding whether a pass statement follows a docstring is not really possible (at least not with a LOT of effort), so the approach is to keep pass statements right after a line ending with triple quotes. This is most probably in 99% of the cases a pass after a docstring.

This adds the possibility of keeping pass statements after docstrings which are not useless and is one of the requested features in the repo, see #73, #10. I know that autoflake will already keep the pass statement if:

  • I leave an empty line after the docstring, but this goes against PEP 0257,
  • or if I use a docstring format which uses # instead of triple-quotes, which is not the case for anyone using Google Style Docstring

Closes #9.
Closes #10.
Closes #73.

Copy link
Collaborator

@fsouza fsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@fsouza fsouza merged commit d389870 into PyCQA:main Sep 18, 2022
@alvarotroya
Copy link
Contributor Author

Thank you!

my pleasure!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants