mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-30 23:27:27 +00:00
Document one-call chaining deviation (#7767)
## Summary I missed this in the prior pass. Closes https://github.com/astral-sh/ruff/issues/7051.
This commit is contained in:
parent
55fa887099
commit
f872c3bf0f
1 changed files with 69 additions and 0 deletions
|
@ -560,3 +560,72 @@ StartElementHandler: (
|
|||
| None
|
||||
)
|
||||
```
|
||||
|
||||
### Call chain calls break differently ([#7051](https://github.com/astral-sh/ruff/issues/7051))
|
||||
|
||||
Black occasionally breaks call chains differently than Ruff; in particular, Black occasionally
|
||||
expands the arguments for the last call in the chain, as in:
|
||||
|
||||
```python
|
||||
# Input
|
||||
df.drop(
|
||||
columns=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
|
||||
).drop_duplicates().rename(
|
||||
columns={
|
||||
"a": "a",
|
||||
}
|
||||
).to_csv(path / "aaaaaa.csv", index=False)
|
||||
|
||||
# Black
|
||||
df.drop(
|
||||
columns=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
|
||||
).drop_duplicates().rename(
|
||||
columns={
|
||||
"a": "a",
|
||||
}
|
||||
).to_csv(
|
||||
path / "aaaaaa.csv", index=False
|
||||
)
|
||||
|
||||
# Ruff
|
||||
df.drop(
|
||||
columns=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
|
||||
).drop_duplicates().rename(
|
||||
columns={
|
||||
"a": "a",
|
||||
}
|
||||
).to_csv(path / "aaaaaa.csv", index=False)
|
||||
```
|
||||
|
||||
Ruff will only expand the arguments if doing so is necessary to fit within the configured line
|
||||
width.
|
||||
|
||||
Note that Black does not apply this last-call argument breaking universally. For example, both
|
||||
Black and Ruff will format the following identically:
|
||||
|
||||
```python
|
||||
# Input
|
||||
df.drop(
|
||||
columns=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]
|
||||
).drop_duplicates(a).rename(
|
||||
columns={
|
||||
"a": "a",
|
||||
}
|
||||
).to_csv(
|
||||
path / "aaaaaa.csv", index=False
|
||||
).other(a)
|
||||
|
||||
# Black
|
||||
df.drop(columns=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]).drop_duplicates(a).rename(
|
||||
columns={
|
||||
"a": "a",
|
||||
}
|
||||
).to_csv(path / "aaaaaa.csv", index=False).other(a)
|
||||
|
||||
# Ruff
|
||||
df.drop(columns=["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]).drop_duplicates(a).rename(
|
||||
columns={
|
||||
"a": "a",
|
||||
}
|
||||
).to_csv(path / "aaaaaa.csv", index=False).other(a)
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue