Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

can_omit_optional_parentheses: Exit early for unparenthesized expressions #9125

Merged

Conversation

MichaReiser
Copy link
Member

Summary

The can_omit_optional_parentheses layout tries to avoid parenthesizing an expression if
breaking any of it's sub-expressions that have their own parentheses make the expression fit.

This PR moves the check whether an expression contains any parenthesized expression further up
to ensure we avoid the slightly more expensive layout when there are no other parentheses by which we can break.

Test Plan

ecosystem check reports no changes

@MichaReiser
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@MichaReiser MichaReiser added internal An internal refactor or improvement formatter Related to the formatter labels Dec 14, 2023
@MichaReiser MichaReiser force-pushed the can-omit-exit-early-for-expressions-without-parens branch from 3411a09 to 1f8f254 Compare December 14, 2023 05:48
Copy link
Contributor

ruff-ecosystem results

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser marked this pull request as ready for review December 14, 2023 06:02
@MichaReiser MichaReiser merged commit c99eae2 into main Dec 14, 2023
17 checks passed
@MichaReiser MichaReiser deleted the can-omit-exit-early-for-expressions-without-parens branch December 14, 2023 06:02
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
formatter Related to the formatter internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant