-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Upgrade RustPython
to access ranged names
#5194
Conversation
61a850a
to
212c368
Compare
212c368
to
06c4538
Compare
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
@@ -622,8 +625,13 @@ fn handle_positional_only_arguments_separator_comment<'a>( | |||
return CommentPlacement::Default(comment); | |||
}; | |||
|
|||
let is_last_positional_argument = are_same_optional(last_argument_or_default, arguments.posonlyargs.last()) | |||
// If the preceding node is the default for the last positional argument | |||
let is_last_positional_argument = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I wonder if we can simplify this now by simply using the argument with default range. Also... did you override the new visit methods in the CommentVisitor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #5204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some other places that could use the new Identifier
range
- Function definition formatting: https://github.com/charliermarsh/ruff/blob/84dd7db9c367e4aeeb2fbfc156a1f760787871e6/crates/ruff_python_formatter/src/statement/stmt_function_def.rs#L88
- Argument formatting https://github.com/charliermarsh/ruff/blob/84dd7db9c367e4aeeb2fbfc156a1f760787871e6/crates/ruff_python_formatter/src/other/arg.rs#L23
06c4538
to
88fbc72
Compare
88fbc72
to
c91090a
Compare
c91090a
to
b921b23
Compare
@@ -53,6 +47,19 @@ syn = { version = "2.0.15" } | |||
test-case = { version = "3.0.0" } | |||
toml = { version = "0.7.2" } | |||
|
|||
# v0.0.1 | |||
libcst = { git = "https://github.com/charliermarsh/LibCST", rev = "80e4c1399f95e5beb532fdd1e209ad2dbb470438" } | |||
# v0.0.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @MichaReiser - I'm going to start documenting these here so that we don't forget to update the tags.
## Summary Now that all identifiers include ranges (#5194), we can remove a ton of this "custom lexing" code that we have to sketchily extract identifier ranges from source. ## Test Plan `cargo test`
Summary
In astral-sh/RustPython-Parser#8, we modified RustPython to include ranges for any identifiers that aren't
Expr::Name
(which already has an identifier).For example, the
e
inexcept ValueError as e
was previously un-ranged. To extract its range, we had to do some lexing of our own. This change should improve performance and let us remove a bunch of code.Test Plan
cargo test