-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
End-of-line comments are ignored when breaking long lines in the formatter #6377
Labels
formatter
Related to the formatter
Milestone
Comments
I haven't looked into this at all, but @MichaReiser has mentioned that this is hard (for line suffixes to be included in the break length). |
Thanks for the detailed report. I don't know if we want to change this. I think you can argue both ways and it adds a fair amount of complexity. See #5630 for the details Closing to track this in a single issue |
Thanks, missed that this was a dupe. |
charliermarsh
added a commit
that referenced
this issue
Aug 7, 2023
) ## Summary Fixes an instability whereby this: ```python def get_recent_deployments(threshold_days: int) -> Set[str]: # Returns a list of deployments not older than threshold days # including `/root/zulip` directory if it exists. recent = set() threshold_date = datetime.datetime.now() - datetime.timedelta( # noqa: DTZ005 days=threshold_days ) ``` Was being formatted as: ```python def get_recent_deployments(threshold_days: int) -> Set[str]: # Returns a list of deployments not older than threshold days # including `/root/zulip` directory if it exists. recent = set() threshold_date = ( datetime.datetime.now() - datetime.timedelta(days=threshold_days) # noqa: DTZ005 ) ``` Which was in turn being formatted as: ```python def get_recent_deployments(threshold_days: int) -> Set[str]: # Returns a list of deployments not older than threshold days # including `/root/zulip` directory if it exists. recent = set() threshold_date = ( datetime.datetime.now() - datetime.timedelta(days=threshold_days) # noqa: DTZ005 ) ``` The second-to-third formattings still differs from Black because we aren't taking the line suffix into account when splitting (#6377), but the first formatting is correct and should be unchanged (i.e., the first-to-second formattings is incorrect, and fixed here). ## Test Plan `cargo run --bin ruff_dev -- format-dev --stability-check ../zulip`
durumu
pushed a commit
to durumu/ruff
that referenced
this issue
Aug 12, 2023
…tral-sh#6376) ## Summary Fixes an instability whereby this: ```python def get_recent_deployments(threshold_days: int) -> Set[str]: # Returns a list of deployments not older than threshold days # including `/root/zulip` directory if it exists. recent = set() threshold_date = datetime.datetime.now() - datetime.timedelta( # noqa: DTZ005 days=threshold_days ) ``` Was being formatted as: ```python def get_recent_deployments(threshold_days: int) -> Set[str]: # Returns a list of deployments not older than threshold days # including `/root/zulip` directory if it exists. recent = set() threshold_date = ( datetime.datetime.now() - datetime.timedelta(days=threshold_days) # noqa: DTZ005 ) ``` Which was in turn being formatted as: ```python def get_recent_deployments(threshold_days: int) -> Set[str]: # Returns a list of deployments not older than threshold days # including `/root/zulip` directory if it exists. recent = set() threshold_date = ( datetime.datetime.now() - datetime.timedelta(days=threshold_days) # noqa: DTZ005 ) ``` The second-to-third formattings still differs from Black because we aren't taking the line suffix into account when splitting (astral-sh#6377), but the first formatting is correct and should be unchanged (i.e., the first-to-second formattings is incorrect, and fixed here). ## Test Plan `cargo run --bin ruff_dev -- format-dev --stability-check ../zulip`
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For example, we treat this as stable formatting:
Whereas we should be formatting it as:
Since the
# noqa: DTZ005
causes the accompanying line to exceed the line length.The text was updated successfully, but these errors were encountered: