-
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
Format call expressions (without call chaining) #5341
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
37fdcdd
to
8bc2b89
Compare
c15c45a
to
ebf1c09
Compare
Cargo.toml
Outdated
#ruff_text_size = { path = "../disk/projects/RustPython-Parser/ruff_text_size" } | ||
#rustpython-ast = { path = "../disk/projects/RustPython-Parser/ast", default-features = false, features = ["num-bigint"] } | ||
#rustpython-format = { path = "../disk/projects/RustPython-Parser/format", default-features = false, features = ["num-bigint"] } | ||
#rustpython-literal = { path = "../disk/projects/RustPython-Parser/literal", default-features = false } | ||
#rustpython-parser = { path = "../disk/projects/RustPython-Parser/parser", default-features = false, features = ["full-lexer", "num-bigint"] } |
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'll remove this before merging
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.
Nice! What's the plan with the failing tests? Do you plan to comment them out for now? Would it help if I took a look (unlikely to be before Wednesday)?
if let Some(arg) = arg { | ||
write!(f, [arg.format(), text("="), value.format()]) | ||
} else { | ||
// TODO(konstin): dangling comments after the stars? |
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 don't think that we have to preserve these. It seems a rather weird place to put comments.
@@ -13,10 +13,11 @@ impl FormatNodeRule<Keyword> for FormatKeyword { | |||
arg, | |||
value, | |||
} = item; | |||
if let Some(argument) = arg { | |||
write!(f, [argument.format(), text("=")])?; | |||
if let Some(arg) = arg { |
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.
Nit: I prefer to move the logic that is common for all branches out of the if
. I find that this improves readability. I otherwise have to manually parse both branches to understand what's the same/different.
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 want to keep those two specifically since they are one entry in a list each and because each branch has its own comment handling
// value . attr | ||
// ^^^^^^^ the range of dangling comments |
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.
Nice!
ebf1c09
to
9a63e21
Compare
Summary
This formats call expressions with magic trailing comma and parentheses behaviour but without call chaining
Test Plan
Lots of new test fixtures, including some that don't work yet