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

Format StmtAugAssign #5655

Merged
merged 1 commit into from
Jul 11, 2023
Merged

Format StmtAugAssign #5655

merged 1 commit into from
Jul 11, 2023

Conversation

konstin
Copy link
Member

@konstin konstin commented Jul 10, 2023

Summary

Format statements such as tree_depth += 1. This is a statement that does not allow any line breaks, the only thing to be mindful of is to parenthesize the assigned expression

Jaccard index on django: 0.915 -> 0.918

Test Plan

black tests, and two new tests, a basic one and one that ensures that the child gets parentheses. I ran the django stability check.

Format statements such as `tree_depth += 1`. This is a statement that does not allow any line breaks, the only thing to be mindful of is to parenthesize the assigned expression
@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      8.0±0.03ms     5.1 MB/sec    1.00      8.0±0.03ms     5.1 MB/sec
formatter/numpy/ctypeslib.py               1.00   1764.7±1.85µs     9.4 MB/sec    1.01   1787.4±2.63µs     9.3 MB/sec
formatter/numpy/globals.py                 1.00    197.3±0.26µs    15.0 MB/sec    1.01    199.3±0.44µs    14.8 MB/sec
formatter/pydantic/types.py                1.01      3.9±0.02ms     6.6 MB/sec    1.00      3.8±0.01ms     6.6 MB/sec
linter/all-rules/large/dataset.py          1.01     13.6±0.05ms     3.0 MB/sec    1.00     13.4±0.05ms     3.0 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      3.4±0.00ms     4.9 MB/sec    1.00      3.4±0.01ms     4.9 MB/sec
linter/all-rules/numpy/globals.py          1.01    435.1±1.50µs     6.8 MB/sec    1.00    431.3±0.62µs     6.8 MB/sec
linter/all-rules/pydantic/types.py         1.01      6.0±0.01ms     4.3 MB/sec    1.00      5.9±0.01ms     4.3 MB/sec
linter/default-rules/large/dataset.py      1.02      6.8±0.02ms     6.0 MB/sec    1.00      6.7±0.01ms     6.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.02   1491.7±3.41µs    11.2 MB/sec    1.00   1467.0±4.99µs    11.4 MB/sec
linter/default-rules/numpy/globals.py      1.02    171.1±0.37µs    17.2 MB/sec    1.00    167.3±1.05µs    17.6 MB/sec
linter/default-rules/pydantic/types.py     1.02      3.1±0.01ms     8.3 MB/sec    1.00      3.0±0.01ms     8.4 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.07     13.0±0.49ms     3.1 MB/sec    1.00     12.1±0.43ms     3.4 MB/sec
formatter/numpy/ctypeslib.py               1.04      2.8±0.11ms     6.0 MB/sec    1.00      2.6±0.11ms     6.3 MB/sec
formatter/numpy/globals.py                 1.03   313.9±17.62µs     9.4 MB/sec    1.00   305.9±13.28µs     9.6 MB/sec
formatter/pydantic/types.py                1.04      6.1±0.20ms     4.2 MB/sec    1.00      5.9±0.22ms     4.3 MB/sec
linter/all-rules/large/dataset.py          1.01     20.6±0.53ms  2019.6 KB/sec    1.00     20.4±0.72ms  2045.8 KB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      5.4±0.21ms     3.1 MB/sec    1.00      5.4±0.25ms     3.1 MB/sec
linter/all-rules/numpy/globals.py          1.05   672.9±32.90µs     4.4 MB/sec    1.00   638.9±23.61µs     4.6 MB/sec
linter/all-rules/pydantic/types.py         1.05      9.4±0.38ms     2.7 MB/sec    1.00      9.0±0.34ms     2.8 MB/sec
linter/default-rules/large/dataset.py      1.04     11.0±0.31ms     3.7 MB/sec    1.00     10.5±0.34ms     3.9 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.06      2.4±0.11ms     7.1 MB/sec    1.00      2.2±0.09ms     7.5 MB/sec
linter/default-rules/numpy/globals.py      1.00   277.8±13.63µs    10.6 MB/sec    1.00   277.1±33.51µs    10.6 MB/sec
linter/default-rules/pydantic/types.py     1.02      4.8±0.20ms     5.3 MB/sec    1.00      4.7±0.17ms     5.5 MB/sec

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

Please update #4798 or create an issue an link it to the PR so that we keep track of the (at least partially) implemented syntax.

write!(
f,
[
target.format(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stmt formatting can be so nice. Expressions are the real pain

@konstin konstin mentioned this pull request Jul 11, 2023
72 tasks
@konstin konstin merged commit b7794f8 into main Jul 11, 2023
16 checks passed
@konstin konstin deleted the format-stmt-aug-assign branch July 11, 2023 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants