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

Pass FormatContext to NeedsParentheses #5643

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

MichaReiser
Copy link
Member

Summary

I started working on this because I assumed that I would need access to options inside of NeedsParantheses but it then turned out that I won't.
Anyway, it kind of felt nice to pass fewer arguments. So I'm gonna put this out here to get your feedback if you prefer this over passing individual fiels.

Oh, I sneeked in another change. I renamed context.contents to source. contents is too generic and doesn't tell you anything.

Test Plan

It compiles

@MichaReiser MichaReiser added the formatter Related to the formatter label Jul 10, 2023
@MichaReiser MichaReiser force-pushed the pass-format-context-to-needs-parentheses branch from 738e9a9 to 2c04bdc Compare July 10, 2023 12:09
@github-actions
Copy link
Contributor

github-actions bot commented Jul 10, 2023

PR Check Results

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.02      9.5±0.05ms     4.3 MB/sec    1.00      9.3±0.09ms     4.4 MB/sec
formatter/numpy/ctypeslib.py               1.02      2.2±0.01ms     7.5 MB/sec    1.00      2.2±0.03ms     7.7 MB/sec
formatter/numpy/globals.py                 1.01    243.3±2.32µs    12.1 MB/sec    1.00    240.2±3.21µs    12.3 MB/sec
formatter/pydantic/types.py                1.00      4.7±0.04ms     5.4 MB/sec    1.00      4.7±0.05ms     5.4 MB/sec
linter/all-rules/large/dataset.py          1.02     16.3±0.14ms     2.5 MB/sec    1.00     16.0±0.22ms     2.5 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.02      4.1±0.01ms     4.1 MB/sec    1.00      4.0±0.04ms     4.2 MB/sec
linter/all-rules/numpy/globals.py          1.00    517.2±3.30µs     5.7 MB/sec    1.00    517.6±5.24µs     5.7 MB/sec
linter/all-rules/pydantic/types.py         1.02      7.2±0.09ms     3.5 MB/sec    1.00      7.1±0.06ms     3.6 MB/sec
linter/default-rules/large/dataset.py      1.01      8.0±0.03ms     5.1 MB/sec    1.00      7.9±0.08ms     5.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.03  1757.8±10.58µs     9.5 MB/sec    1.00  1710.5±15.48µs     9.7 MB/sec
linter/default-rules/numpy/globals.py      1.01    198.6±1.04µs    14.9 MB/sec    1.00    196.7±1.88µs    15.0 MB/sec
linter/default-rules/pydantic/types.py     1.02      3.6±0.01ms     7.0 MB/sec    1.00      3.6±0.03ms     7.2 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.12      7.9±0.25ms     5.2 MB/sec    1.00      7.0±0.30ms     5.8 MB/sec
formatter/numpy/ctypeslib.py               1.13  1750.9±35.89µs     9.5 MB/sec    1.00  1547.5±15.16µs    10.8 MB/sec
formatter/numpy/globals.py                 1.05    174.6±4.55µs    16.9 MB/sec    1.00    166.2±2.86µs    17.7 MB/sec
formatter/pydantic/types.py                1.17      4.0±0.09ms     6.4 MB/sec    1.00      3.4±0.03ms     7.5 MB/sec
linter/all-rules/large/dataset.py          1.01     14.4±0.94ms     2.8 MB/sec    1.00     14.3±0.22ms     2.8 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      3.6±0.46ms     4.6 MB/sec    1.10      3.9±0.06ms     4.2 MB/sec
linter/all-rules/numpy/globals.py          1.00   366.9±36.02µs     8.0 MB/sec    1.08   395.7±11.56µs     7.5 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.3±0.40ms     4.8 MB/sec    1.24      6.6±0.09ms     3.9 MB/sec
linter/default-rules/large/dataset.py      1.00      5.9±0.12ms     6.8 MB/sec    1.12      6.7±0.68ms     6.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.05  1298.3±16.30µs    12.8 MB/sec    1.00  1234.1±16.53µs    13.5 MB/sec
linter/default-rules/numpy/globals.py      1.04    135.7±2.29µs    21.7 MB/sec    1.00    130.2±0.98µs    22.7 MB/sec
linter/default-rules/pydantic/types.py     1.06      2.9±0.05ms     8.9 MB/sec    1.00      2.7±0.04ms     9.4 MB/sec

Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

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

I like it!

Copy link
Member

@konstin konstin left a comment

Choose a reason for hiding this comment

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

Oh, I sneeked in another change. I renamed context.contents to source. contents is too generic and doesn't tell you anything.

that's a good change

@MichaReiser MichaReiser force-pushed the remove-best-fitting-mode branch from 0c7c03d to b754a0d Compare July 11, 2023 11:30
@MichaReiser MichaReiser force-pushed the pass-format-context-to-needs-parentheses branch from 0681c5e to c895628 Compare July 11, 2023 11:30
@MichaReiser MichaReiser force-pushed the remove-best-fitting-mode branch from b754a0d to 51c4306 Compare July 11, 2023 12:10
Base automatically changed from remove-best-fitting-mode to main July 11, 2023 12:19
@MichaReiser
Copy link
Member Author

Graphite rebased this pull request after merging its parent, because this pull request is set to merge when ready.

@MichaReiser MichaReiser force-pushed the pass-format-context-to-needs-parentheses branch from c895628 to 553008e Compare July 11, 2023 12:20
@MichaReiser MichaReiser merged commit 8665a1a into main Jul 11, 2023
@MichaReiser MichaReiser deleted the pass-format-context-to-needs-parentheses branch July 11, 2023 12:28
@MichaReiser
Copy link
Member Author

@MichaReiser merged this pull request with Graphite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
formatter Related to the formatter
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants