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

Introduce ExpressionRef #5644

Closed
wants to merge 1 commit into from
Closed

Introduce ExpressionRef #5644

wants to merge 1 commit into from

Conversation

MichaReiser
Copy link
Member

Summary

Same as for the previous PR. I assumed that I would need to match on all Expr and this isn't easily possible with AnyNodeRef.
That's why I introduced a new ExpressionRef which is the unowned pendant to Expr. There are a few cases where it allows me to remove some debug assertions, but I didn't end up using it heavily.

We can merge it if you find it useful, or leave it as is.

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

Ecosystem

✅ ecosystem check detected no changes.

Benchmark

Linux

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.08      8.6±0.02ms     4.8 MB/sec    1.00      7.9±0.03ms     5.1 MB/sec
formatter/numpy/ctypeslib.py               1.06   1952.8±3.13µs     8.5 MB/sec    1.00   1846.2±4.18µs     9.0 MB/sec
formatter/numpy/globals.py                 1.03    211.4±0.28µs    14.0 MB/sec    1.00    205.3±4.79µs    14.4 MB/sec
formatter/pydantic/types.py                1.06      4.2±0.01ms     6.1 MB/sec    1.00      4.0±0.00ms     6.4 MB/sec
linter/all-rules/large/dataset.py          1.00     13.4±0.07ms     3.0 MB/sec    1.00     13.5±0.03ms     3.0 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.00      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.00    432.4±1.03µs     6.8 MB/sec    1.00    433.8±0.52µs     6.8 MB/sec
linter/all-rules/pydantic/types.py         1.01      6.0±0.02ms     4.2 MB/sec    1.00      6.0±0.02ms     4.3 MB/sec
linter/default-rules/large/dataset.py      1.00      6.7±0.01ms     6.1 MB/sec    1.01      6.7±0.01ms     6.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1459.0±2.85µs    11.4 MB/sec    1.00   1465.6±4.23µs    11.4 MB/sec
linter/default-rules/numpy/globals.py      1.00    166.0±0.27µs    17.8 MB/sec    1.01    167.3±0.22µs    17.6 MB/sec
linter/default-rules/pydantic/types.py     1.00      3.0±0.01ms     8.4 MB/sec    1.00      3.0±0.01ms     8.4 MB/sec

Windows

group                                      main                                   pr
-----                                      ----                                   --
formatter/large/dataset.py                 1.00      7.7±0.03ms     5.3 MB/sec    1.00      7.7±0.03ms     5.3 MB/sec
formatter/numpy/ctypeslib.py               1.01   1696.8±7.94µs     9.8 MB/sec    1.00  1687.2±10.30µs     9.9 MB/sec
formatter/numpy/globals.py                 1.01    179.0±1.46µs    16.5 MB/sec    1.00   178.0±12.96µs    16.6 MB/sec
formatter/pydantic/types.py                1.00      3.7±0.02ms     6.9 MB/sec    1.00      3.7±0.02ms     6.9 MB/sec
linter/all-rules/large/dataset.py          1.00     12.7±0.05ms     3.2 MB/sec    1.00     12.7±0.04ms     3.2 MB/sec
linter/all-rules/numpy/ctypeslib.py        1.01      3.3±0.01ms     5.1 MB/sec    1.00      3.2±0.01ms     5.1 MB/sec
linter/all-rules/numpy/globals.py          1.00    345.1±2.41µs     8.6 MB/sec    1.00    346.1±3.82µs     8.5 MB/sec
linter/all-rules/pydantic/types.py         1.00      5.6±0.02ms     4.5 MB/sec    1.00      5.6±0.02ms     4.5 MB/sec
linter/default-rules/large/dataset.py      1.00      6.6±0.03ms     6.2 MB/sec    1.01      6.6±0.02ms     6.1 MB/sec
linter/default-rules/numpy/ctypeslib.py    1.00   1334.3±8.22µs    12.5 MB/sec    1.00   1335.1±7.38µs    12.5 MB/sec
linter/default-rules/numpy/globals.py      1.00    146.6±1.19µs    20.1 MB/sec    1.00    146.6±0.94µs    20.1 MB/sec
linter/default-rules/pydantic/types.py     1.00      2.9±0.02ms     8.8 MB/sec    1.00      2.9±0.01ms     8.8 MB/sec

@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 pass-format-context-to-needs-parentheses branch from c895628 to 553008e Compare July 11, 2023 12:20
Base automatically changed from pass-format-context-to-needs-parentheses to main July 11, 2023 12:28
@MichaReiser
Copy link
Member Author

Closing for now as it isn't needed right way. We can reconsider adding ExpressionRef when the need arises.

charliermarsh added a commit that referenced this pull request Aug 17, 2023
## Summary

This PR revives the `ExpressionRef` concept introduced in
#5644, motivated by the change we
want to make in #6575 to narrow
the type of the expression that can be passed to `parenthesized_range`.

## Test Plan

`cargo test`
@MichaReiser MichaReiser deleted the expression-ref branch January 16, 2024 10:03
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.

2 participants