Commit 30bec3f
authored
Only omit optinal parens if the expression ends or starts with a parenthesized expression
<!--
Thank you for contributing to Ruff! To help us out with reviewing, please consider the following:
- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->
## Summary
This PR matches Black' behavior where it only omits the optional parentheses if the expression starts or ends with a parenthesized expression:
```python
a + [aaa, bbb, cccc] * c # Don't omit
[aaa, bbb, cccc] + a * c # Split
a + c * [aaa, bbb, ccc] # Split
```
<!-- What's the purpose of the change? What does it do, and why? -->
## Test Plan
This improves the Jaccard index from 0.945 to 0.9461 parent 8b9193a commit 30bec3f
File tree
3 files changed
+43
-159
lines changed- crates/ruff_python_formatter
- src
- expression
- tests/snapshots
3 files changed
+43
-159
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
| 201 | + | |
203 | 202 | | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
| 203 | + | |
215 | 204 | | |
216 | 205 | | |
217 | 206 | | |
218 | | - | |
| 207 | + | |
219 | 208 | | |
220 | 209 | | |
221 | 210 | | |
| 211 | + | |
| 212 | + | |
222 | 213 | | |
223 | 214 | | |
224 | 215 | | |
225 | | - | |
| 216 | + | |
226 | 217 | | |
227 | 218 | | |
228 | 219 | | |
229 | 220 | | |
230 | 221 | | |
231 | 222 | | |
| 223 | + | |
| 224 | + | |
232 | 225 | | |
233 | 226 | | |
234 | 227 | | |
| |||
305 | 298 | | |
306 | 299 | | |
307 | 300 | | |
| 301 | + | |
308 | 302 | | |
309 | 303 | | |
310 | 304 | | |
| |||
351 | 345 | | |
352 | 346 | | |
353 | 347 | | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
360 | 366 | | |
361 | 367 | | |
362 | 368 | | |
363 | | - | |
| 369 | + | |
364 | 370 | | |
| 371 | + | |
| 372 | + | |
365 | 373 | | |
366 | 374 | | |
367 | 375 | | |
368 | 376 | | |
369 | 377 | | |
370 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
371 | 383 | | |
372 | 384 | | |
373 | 385 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
285 | 292 | | |
286 | 293 | | |
287 | 294 | | |
| |||
Lines changed: 0 additions & 135 deletions
This file was deleted.
0 commit comments