Skip to content

Classify match not foo as keyword#11626

Merged
dhruvmanila merged 1 commit intodhruv/parser-phase-2from
dhruv/match-not
May 31, 2024
Merged

Classify match not foo as keyword#11626
dhruvmanila merged 1 commit intodhruv/parser-phase-2from
dhruv/match-not

Conversation

@dhruvmanila
Copy link
Member

Summary

This PR fixes a bug to classify match as a keyword for:

match not foo:
    case _: ...

Test Plan

This PR also adds a bunch of test cases around the classification of match token as a keyword or an identifier, including speculative parsing.

@dhruvmanila dhruvmanila added bug Something isn't working testing Related to testing Ruff itself labels May 31, 2024
@dhruvmanila dhruvmanila requested a review from MichaReiser as a code owner May 31, 2024 04:45
Comment on lines 3574 to 3576
| TokenKind::Ellipsis
| TokenKind::Not
| TokenKind::Await
Copy link
Member Author

Choose a reason for hiding this comment

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

The bug fix.

@dhruvmanila dhruvmanila merged commit c646d0a into dhruv/parser-phase-2 May 31, 2024
@dhruvmanila dhruvmanila deleted the dhruv/match-not branch May 31, 2024 04:46
@codspeed-hq
Copy link

codspeed-hq bot commented May 31, 2024

CodSpeed Performance Report

Merging #11626 will improve performances by 28.14%

Comparing dhruv/match-not (2c10479) with main (685d11a)

Summary

⚡ 19 improvements
✅ 11 untouched benchmarks

Benchmarks breakdown

Benchmark main dhruv/match-not Change
lexer[large/dataset.py] 1.4 ms 1.1 ms +27.63%
lexer[numpy/ctypeslib.py] 284.3 µs 225.8 µs +25.9%
lexer[numpy/globals.py] 36.7 µs 29.7 µs +23.73%
lexer[pydantic/types.py] 639.9 µs 503 µs +27.22%
lexer[unicode/pypinyin.py] 98.3 µs 76.7 µs +28.14%
linter/all-rules[large/dataset.py] 16.9 ms 15.9 ms +6.15%
linter/all-rules[numpy/ctypeslib.py] 4.1 ms 3.9 ms +4.97%
linter/all-rules[pydantic/types.py] 8.2 ms 7.6 ms +7.02%
linter/all-rules[unicode/pypinyin.py] 2.1 ms 2 ms +4.64%
linter/default-rules[large/dataset.py] 4.3 ms 3.6 ms +18.49%
linter/default-rules[numpy/ctypeslib.py] 1,013.7 µs 941.3 µs +7.69%
linter/default-rules[pydantic/types.py] 2.1 ms 1.9 ms +11.85%
linter/default-rules[unicode/pypinyin.py] 406 µs 359.6 µs +12.89%
linter/all-with-preview-rules[large/dataset.py] 20.3 ms 19.3 ms +4.94%
parser[large/dataset.py] 5.7 ms 5.2 ms +10.19%
parser[numpy/ctypeslib.py] 1,161.7 µs 991.5 µs +17.17%
parser[numpy/globals.py] 122.2 µs 105.9 µs +15.44%
parser[pydantic/types.py] 2.3 ms 2.2 ms +5.97%
parser[unicode/pypinyin.py] 371.3 µs 337.8 µs +9.92%

dhruvmanila added a commit that referenced this pull request May 31, 2024
## Summary

This PR fixes a bug to classify `match` as a keyword for:
```py
match not foo:
    case _: ...
```

## Test Plan

This PR also adds a bunch of test cases around the classification of
`match` token as a keyword or an identifier, including speculative
parsing.
dhruvmanila added a commit that referenced this pull request Jun 3, 2024
## Summary

This PR fixes a bug to classify `match` as a keyword for:
```py
match not foo:
    case _: ...
```

## Test Plan

This PR also adds a bunch of test cases around the classification of
`match` token as a keyword or an identifier, including speculative
parsing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working testing Related to testing Ruff itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant