mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Use parenthesized_with_dangling_comments
in arguments formatter (#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 (https://github.com/astral-sh/ruff/issues/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`
This commit is contained in:
parent
89e4e038b0
commit
63692b3798
3 changed files with 30 additions and 15 deletions
|
@ -117,6 +117,10 @@ f (
|
|||
1
|
||||
# abc
|
||||
)
|
||||
|
||||
threshold_date = datetime.datetime.now() - datetime.timedelta( # comment
|
||||
days=threshold_days_threshold_days
|
||||
)
|
||||
```
|
||||
|
||||
## Output
|
||||
|
@ -230,6 +234,10 @@ f(
|
|||
1
|
||||
# abc
|
||||
)
|
||||
|
||||
threshold_date = datetime.datetime.now() - datetime.timedelta( # comment
|
||||
days=threshold_days_threshold_days
|
||||
)
|
||||
```
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue