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

Lexer start of line is false only for Mode::Expression #8880

Merged
merged 2 commits into from
Nov 28, 2023

Conversation

dhruvmanila
Copy link
Member

@dhruvmanila dhruvmanila commented Nov 28, 2023

Summary

This PR fixes the bug in the lexer where the Mode::Ipython wasn't being considered when initializing the soft keyword transformer which wraps the lexer. This means that if the source code starts with either match or type keyword, then the keywords were being considered as name tokens instead. For example,

match foo:
    case bar:
        pass

This would transform the match keyword into an identifier if the mode is Ipython.

The fix is to reverse the condition in the soft keyword initializer so that any new modes are by default considered as the lexer being at start of line.

Test Plan

Add a new test case for Mode::Ipython and verify the snapshot.

fixes: #8870

@dhruvmanila
Copy link
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@dhruvmanila dhruvmanila added bug Something isn't working parser Related to the parser labels Nov 28, 2023
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.

Wow, that's devious

@dhruvmanila dhruvmanila enabled auto-merge (squash) November 28, 2023 20:36
@dhruvmanila dhruvmanila merged commit 47d80f2 into main Nov 28, 2023
16 checks passed
@dhruvmanila dhruvmanila deleted the dhruv/soft-keyword branch November 28, 2023 20:38
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Formatter (stable)

✅ ecosystem check detected no format changes.

Formatter (preview)

✅ ecosystem check detected no format changes.

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 this pull request may close these issues.

ruff formatting not working if match statements exists anywhere (vscode; vscode extension; ipynb)
2 participants