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

Incorrect range for WithItem node #8913

Closed
LaBatata101 opened this issue Nov 29, 2023 · 1 comment · Fixed by #8915
Closed

Incorrect range for WithItem node #8913

LaBatata101 opened this issue Nov 29, 2023 · 1 comment · Fixed by #8915
Assignees
Labels
bug Something isn't working parser Related to the parser

Comments

@LaBatata101
Copy link
Contributor

Ruff version: v0.1.6

In the following code snippet

with (a := b) as x: pass

The WithItem range is 6..17 which contains this part of the source code a := b) as, as you can see the left parenthesis and the x is missing from the range. The correct range would be 5..18.

Here is the AST.

@MichaReiser MichaReiser added bug Something isn't working parser Related to the parser labels Nov 29, 2023
@charliermarsh
Copy link
Member

Odd, I can take a look at this.

@charliermarsh charliermarsh self-assigned this Nov 30, 2023
charliermarsh added a commit that referenced this issue Nov 30, 2023
## Summary

Given `with (a := b): pass`, we truncate the `WithItem` range by one on
both sides such that the parentheses are part of the statement, rather
than the item. However, for `with (a := b) as x: pass`, we want to avoid
this trick.

Closes #8913.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working parser Related to the parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants