-
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
Add formatting of type parameters in class and function definitions #6161
Conversation
PR Check ResultsEcosystem✅ ecosystem check detected no changes. BenchmarkLinux
Windows
|
Ooooh yes |
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.
Niiiice! This is looking good. I have two test cases that I recommend you adding and I think we can move some more logic into the clause formatting helper.
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/function.py
Outdated
Show resolved
Hide resolved
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/function.py
Outdated
Show resolved
Hide resolved
crates/ruff_python_formatter/src/type_param/type_param_param_spec.rs
Outdated
Show resolved
Hide resolved
crates/ruff_python_formatter/src/type_param/type_param_type_var_tuple.rs
Outdated
Show resolved
Hide resolved
crates/ruff_python_formatter/src/type_param/type_param_clause.rs
Outdated
Show resolved
Hide resolved
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py
Show resolved
Hide resolved
crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/function.py
Outdated
Show resolved
Hide resolved
655d055
to
4ac79ac
Compare
@@ -563,6 +564,51 @@ fn handle_own_line_comment_after_branch<'a>( | |||
} | |||
} | |||
|
|||
/// Attach an enclosed end-of-line comment to a set of [`TypeParams`]. |
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.
As implemented in #6274
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 great.
4ac79ac
to
3660033
Compare
Part of #5062
Closes #5931
Implements formatting of a sequence of type parameters in a dedicated struct for reuse by classes, functions, and type aliases (preparing for #5929). Adds formatting of type parameters in class and function definitions — previously, they were just elided.