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

Fix binary expression formatting with leading comments #4964

Merged
merged 1 commit into from
Jun 9, 2023

Conversation

MichaReiser
Copy link
Member

@MichaReiser MichaReiser commented Jun 8, 2023

Summary

This PR fixes an issue where

if (
    aaaaaaaaaaaaaaaaaa +
    # has the child process finished?
    bbbbbbbbbbbbbbb +
    # the child process has finished, but the
    # transport hasn't been notified yet?
    ccccccccccc
):
    pass

got formatted differently on the second pass.

It now preserves the formatting, the same as Black.

Test Plan

I added a new test

@MichaReiser MichaReiser mentioned this pull request Jun 8, 2023
@MichaReiser MichaReiser requested a review from konstin June 8, 2023 15:31
@MichaReiser MichaReiser marked this pull request as ready for review June 8, 2023 15:31
@MichaReiser MichaReiser added internal An internal refactor or improvement formatter Related to the formatter labels Jun 8, 2023
@MichaReiser MichaReiser force-pushed the format-if-statement branch from b25a3ac to 226aabf Compare June 8, 2023 15:34
@MichaReiser MichaReiser force-pushed the fix-bin-oip-with-leading-comments branch 2 times, most recently from 7e0f1f6 to 5e7fb65 Compare June 8, 2023 15:37
@MichaReiser MichaReiser force-pushed the format-if-statement branch from 226aabf to b9826c1 Compare June 8, 2023 16:10
@MichaReiser MichaReiser force-pushed the fix-bin-oip-with-leading-comments branch from 5e7fb65 to 4cf24dc Compare June 8, 2023 16:10
@github-actions
Copy link
Contributor

github-actions bot commented Jun 8, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.58      9.1±0.05ms     4.4 MB/sec    1.00      5.8±0.10ms     7.0 MB/sec
formatter/numpy/ctypeslib.py               1.51   1831.7±4.64µs     9.1 MB/sec    1.00  1216.8±44.01µs    13.7 MB/sec
formatter/numpy/globals.py                 1.48    173.4±2.59µs    17.0 MB/sec    1.00    117.0±5.98µs    25.2 MB/sec
formatter/pydantic/types.py                1.51      3.7±0.01ms     7.0 MB/sec    1.00      2.4±0.12ms    10.5 MB/sec
linter/all-rules/large/dataset.py          1.00     16.5±0.04ms     2.5 MB/sec    1.03     17.0±0.26ms     2.4 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      4.0±0.01ms     4.2 MB/sec    1.00      4.0±0.01ms     4.2 MB/sec
linter/all-rules/numpy/globals.py          1.00    497.9±0.59µs     5.9 MB/sec    1.00    498.7±0.97µs     5.9 MB/sec
linter/all-rules/pydantic/types.py         1.00      6.9±0.01ms     3.7 MB/sec    1.06      7.3±0.10ms     3.5 MB/sec
linter/default-rules/large/dataset.py      1.11      8.1±0.07ms     5.0 MB/sec    1.00      7.3±0.72ms     5.5 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.30   1754.2±3.45µs     9.5 MB/sec    1.00  1353.0±33.42µs    12.3 MB/sec
linter/default-rules/numpy/globals.py      1.30    196.8±0.33µs    15.0 MB/sec    1.00    150.8±4.77µs    19.6 MB/sec
linter/default-rules/pydantic/types.py     1.30      3.6±0.01ms     7.0 MB/sec    1.00      2.8±0.07ms     9.1 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      9.3±0.29ms     4.4 MB/sec    1.03      9.5±0.33ms     4.3 MB/sec
formatter/numpy/ctypeslib.py               1.00  1848.5±59.76µs     9.0 MB/sec    1.04  1920.1±74.03µs     8.7 MB/sec
formatter/numpy/globals.py                 1.00    186.2±7.17µs    15.9 MB/sec    1.02    189.8±9.23µs    15.5 MB/sec
formatter/pydantic/types.py                1.00      3.8±0.13ms     6.7 MB/sec    1.00      3.8±0.12ms     6.7 MB/sec
linter/all-rules/large/dataset.py          1.00     20.3±0.84ms     2.0 MB/sec    1.08     21.8±1.30ms  1912.7 KB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      5.1±0.21ms     3.2 MB/sec    1.00      5.1±0.20ms     3.3 MB/sec
linter/all-rules/numpy/globals.py          1.00   575.1±53.42µs     5.1 MB/sec    1.05   606.3±33.50µs     4.9 MB/sec
linter/all-rules/pydantic/types.py         1.02      8.9±0.46ms     2.9 MB/sec    1.00      8.7±0.32ms     2.9 MB/sec
linter/default-rules/large/dataset.py      1.00      9.6±0.35ms     4.2 MB/sec    1.15     11.1±0.28ms     3.7 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00      2.1±0.07ms     8.0 MB/sec    1.07      2.2±0.06ms     7.5 MB/sec
linter/default-rules/numpy/globals.py      1.00    242.6±6.95µs    12.2 MB/sec    1.07   258.5±11.39µs    11.4 MB/sec
linter/default-rules/pydantic/types.py     1.00      4.5±0.16ms     5.7 MB/sec    1.08      4.9±0.15ms     5.2 MB/sec

@MichaReiser MichaReiser force-pushed the fix-bin-oip-with-leading-comments branch from 4cf24dc to 7458b5b Compare June 9, 2023 08:46
Base automatically changed from format-if-statement to main June 9, 2023 08:55
@MichaReiser MichaReiser force-pushed the fix-bin-oip-with-leading-comments branch from 7458b5b to e341c1c Compare June 9, 2023 08:56
@MichaReiser MichaReiser enabled auto-merge (squash) June 9, 2023 08:56
@MichaReiser MichaReiser merged commit 646ab64 into main Jun 9, 2023
@MichaReiser MichaReiser deleted the fix-bin-oip-with-leading-comments branch June 9, 2023 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter internal An internal refactor or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants