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

Remove parentheses around simple top-level expressions #4231

Open
JelleZijlstra opened this issue Feb 13, 2024 · 0 comments
Open

Remove parentheses around simple top-level expressions #4231

JelleZijlstra opened this issue Feb 13, 2024 · 0 comments
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. T: enhancement New feature or request

Comments

@JelleZijlstra
Copy link
Collaborator

% cat parens.py 
(x)
(1)
(yield 42)
([])
({})
(a + b)
% black --unstable --diff parens.py
All done! ✨ 🍰 ✨
1 file would be left unchanged.

I think all of these parentheses should be removed.

We should keep parentheses around a top-level expression (ast.Expr) only if:

  • There is a comment associated with the parentheses
  • It's a ternary split into multiple lines
  • Possibly other cases I haven't thought of
@JelleZijlstra JelleZijlstra added T: enhancement New feature or request F: parentheses Too many parentheses, not enough parentheses, and so on. labels Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. T: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant