-
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 class
definitions
#5289
Format class
definitions
#5289
Conversation
Current dependencies on/for this PR:
This comment was auto-generated by Graphite. |
@@ -50,15 +50,15 @@ toml = { version = "0.7.2" } | |||
# v0.0.1 | |||
libcst = { git = "https://github.com/charliermarsh/LibCST", rev = "80e4c1399f95e5beb532fdd1e209ad2dbb470438" } | |||
# v0.0.3 | |||
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "08ebbe40d7776cac6e3ba66277d435056f2b8dca" } | |||
ruff_text_size = { git = "https://github.com/astral-sh/RustPython-Parser.git", rev = "f60e204b73b95bdb6ce87ccd0de34081b4a17c11" } |
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.
Pulls in astral-sh/RustPython-Parser#14
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.
Jepee
.. | ||
} = self.class_definition; | ||
|
||
let separator = format_with(|f| write!(f, [text(","), soft_line_break_or_space()])); |
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.
We should probably extract a helper at some point that joins a list with ,
and soft_line_break_or_space
and preserves any trailing magic comma.
b8cc710
to
5acb7be
Compare
// Manually handle parentheses here because the expression is parenthesized incorrectly assumes that the | ||
// parentheses from the inheritance clause belong to the expression. |
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.
don't understand that comment
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 reworded the comment and added an example.
class_definition: &'a StmtClassDef, | ||
} | ||
|
||
impl Format<PyFormatContext<'_>> for FormatInheritanceClause<'_> { |
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.
Is this effectively formatting a function call?
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.
It's similar but it doesn't need to support any of the complexity like chaining.
5acb7be
to
4967e08
Compare
4967e08
to
132b654
Compare
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
132b654
to
5a7f9b1
Compare
Summary
This PR adds basic formatting for
class
definitions.Test Plan
Ran the stability check to verify that the class definition formatting does not introduce any new instabilities.
Added new snapshot tests.