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

Add formatting of type parameters in class and function definitions #6161

Merged
merged 1 commit into from
Aug 2, 2023

Conversation

zanieb
Copy link
Member

@zanieb zanieb commented Jul 28, 2023

Part of #5062
Closes #5931

Implements formatting of a sequence of type parameters in a dedicated struct for reuse by classes, functions, and type aliases (preparing for #5929). Adds formatting of type parameters in class and function definitions — previously, they were just elided.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 28, 2023

PR Check Results

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      8.3±0.13ms     4.9 MB/sec    1.00      8.3±0.15ms     4.9 MB/sec
formatter/numpy/ctypeslib.py               1.02  1675.5±59.89µs     9.9 MB/sec    1.00  1648.6±31.97µs    10.1 MB/sec
formatter/numpy/globals.py                 1.00    186.7±6.27µs    15.8 MB/sec    1.01    188.1±6.58µs    15.7 MB/sec
formatter/pydantic/types.py                1.01      3.6±0.14ms     7.1 MB/sec    1.00      3.5±0.10ms     7.2 MB/sec
linter/all-rules/large/dataset.py          1.00     10.8±0.05ms     3.8 MB/sec    1.00     10.8±0.04ms     3.8 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      2.8±0.03ms     6.0 MB/sec    1.00      2.8±0.02ms     6.0 MB/sec
linter/all-rules/numpy/globals.py          1.00    381.1±2.22µs     7.7 MB/sec    1.00    380.1±2.35µs     7.8 MB/sec
linter/all-rules/pydantic/types.py         1.00      4.9±0.03ms     5.2 MB/sec    1.03      5.0±0.13ms     5.1 MB/sec
linter/default-rules/large/dataset.py      1.00      5.7±0.04ms     7.1 MB/sec    1.01      5.8±0.05ms     7.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1196.6±4.60µs    13.9 MB/sec    1.00   1194.1±7.16µs    13.9 MB/sec
linter/default-rules/numpy/globals.py      1.00    132.6±1.71µs    22.3 MB/sec    1.00    132.4±1.29µs    22.3 MB/sec
linter/default-rules/pydantic/types.py     1.00      2.5±0.03ms    10.2 MB/sec    1.01      2.5±0.04ms    10.1 MB/sec

Windows

group                                      main                                    pr
-----                                      ----                                    --
formatter/large/dataset.py                 1.01     12.6±0.77ms     3.2 MB/sec     1.00     12.5±0.76ms     3.2 MB/sec
formatter/numpy/ctypeslib.py               1.04      2.5±0.19ms     6.6 MB/sec     1.00      2.4±0.19ms     6.9 MB/sec
formatter/numpy/globals.py                 1.00   261.8±20.98µs    11.3 MB/sec     1.01   265.4±25.19µs    11.1 MB/sec
formatter/pydantic/types.py                1.04      5.5±0.41ms     4.7 MB/sec     1.00      5.3±0.35ms     4.8 MB/sec
linter/all-rules/large/dataset.py          1.00     17.2±0.85ms     2.4 MB/sec     1.01     17.5±1.13ms     2.3 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.02      4.6±0.34ms     3.6 MB/sec     1.00      4.5±0.38ms     3.7 MB/sec
linter/all-rules/numpy/globals.py          1.00   556.2±56.95µs     5.3 MB/sec     1.01   560.0±50.88µs     5.3 MB/sec
linter/all-rules/pydantic/types.py         1.00      7.8±0.45ms     3.3 MB/sec     1.02      7.9±0.47ms     3.2 MB/sec
linter/default-rules/large/dataset.py      1.00      9.5±0.51ms     4.3 MB/sec     1.00      9.5±0.64ms     4.3 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00  1926.2±129.22µs     8.6 MB/sec    1.00  1921.8±117.94µs     8.7 MB/sec
linter/default-rules/numpy/globals.py      1.00   216.3±23.63µs    13.6 MB/sec     1.05   226.6±27.81µs    13.0 MB/sec
linter/default-rules/pydantic/types.py     1.01      4.2±0.31ms     6.0 MB/sec     1.00      4.2±0.35ms     6.1 MB/sec

@charliermarsh
Copy link
Member

Ooooh yes

@zanieb zanieb marked this pull request as ready for review July 28, 2023 20:12
@konstin konstin mentioned this pull request Jul 31, 2023
72 tasks
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.

Niiiice! This is looking good. I have two test cases that I recommend you adding and I think we can move some more logic into the clause formatting helper.

@konstin konstin added the formatter Related to the formatter label Jul 31, 2023
@zanieb zanieb mentioned this pull request Jul 31, 2023
@zanieb zanieb force-pushed the zanie/695-format branch 5 times, most recently from 655d055 to 4ac79ac Compare August 2, 2023 16:07
@@ -563,6 +564,51 @@ fn handle_own_line_comment_after_branch<'a>(
}
}

/// Attach an enclosed end-of-line comment to a set of [`TypeParams`].
Copy link
Member Author

Choose a reason for hiding this comment

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

As implemented in #6274

Copy link
Member

@charliermarsh charliermarsh left a comment

Choose a reason for hiding this comment

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

Looks great.

@zanieb zanieb enabled auto-merge (squash) August 2, 2023 20:21
@zanieb zanieb merged commit 1a60d1e into main Aug 2, 2023
16 checks passed
@zanieb zanieb deleted the zanie/695-format branch August 2, 2023 20:29
zanieb added a commit that referenced this pull request Aug 2, 2023
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.

Format type parameters on functions and classes
4 participants