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

Inline trailing comments for type alias similar to assignments #8941

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Dec 1, 2023

Summary

This PR aligns the comment formatting for type aliases with the assignment formatting.

Black and Ruff inline a trailing assignment comment into the parentheses of the value if the value gets parenthesized.
Neither Black or Ruff apply this layout for type assignments today. To me, this feels inconsistent because type alias statements are just a specific form of assignment.

Note that this is a Black divergence. Depending on the ecosystem check results, we should consider hiding this behind preview for now. Although I don't expect this to be common, considering that type aliases are new.

Test Plan

Added tests.

The similarity index remain unchanged.

project similarity index total files changed files
cpython 0.75804 1799 1648
django 0.99984 2772 34
home-assistant 0.99955 10596 213
poetry 0.96208 317 35
transformers 0.99967 2657 324
twine 1.00000 33 0
typeshed 0.99980 3669 18
warehouse 0.99976 654 14
zulip 0.99957 1459 36

@MichaReiser MichaReiser changed the title cccccbhcgljulfeerhjebkiinfkinldefjgtnteuhttu Inline trailing comments for type alias similar to assignments Dec 1, 2023
@MichaReiser MichaReiser added the formatter Related to the formatter label Dec 1, 2023
Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

I think this is correct.

Copy link
Contributor

github-actions bot commented Dec 1, 2023

ruff-ecosystem results

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

@MichaReiser MichaReiser force-pushed the refactor-last-statement-expression-comment-formatting branch from 76110f7 to 1de4fcd Compare December 1, 2023 04:41
@MichaReiser MichaReiser force-pushed the align-type-alias-with-assignment-formatting branch from 25a55eb to 7d948b2 Compare December 1, 2023 04:41
Base automatically changed from refactor-last-statement-expression-comment-formatting to main December 4, 2023 05:12
@MichaReiser MichaReiser force-pushed the align-type-alias-with-assignment-formatting branch from 7d948b2 to 8fbb3c8 Compare December 4, 2023 05:15
@MichaReiser MichaReiser merged commit 0bf0aa2 into main Dec 4, 2023
17 checks passed
@MichaReiser MichaReiser deleted the align-type-alias-with-assignment-formatting branch December 4, 2023 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants