-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Wrapping lines of a function signature that uses the new python 3.12 generic type parameter syntax #4071
Comments
Yes, we should change this. PR welcome! |
What is the ETA on this? |
Are you interested in making a PR? |
Well, sadly I don't quite have the time for that right now. |
@JackismyShephard if you need to undo what |
FYI: An attempt to fix this is found in #4272 but doesn't seem trivial. |
I just converted a large-ish code-base to the new syntax and found an even more egregious example. 😅 I thought that this example could maybe serve as an additional test case where the return type is also wrapped: def something_something_function[
T: Model
](param: list[int], other_param: type[T], *, some_other_param: bool = True) -> QuerySet[
T
]:
pass Where I would prefer this instead. :) def something_something_function[T: Model](
param: list[int], other_param: type[T], *, some_other_param: bool = True
) -> QuerySet[T]:
pass |
ContextI am currently working on a PR for this, and I am facing some doubts on what should be the valid syntax on some trailing comma cases: def trailing_comma1[T=int,](a: str):
pass
def trailing_comma2[T=int](a: str,):
pass Current BehaviourRight now the expected output in the def trailing_comma1[
T = int,
](a: str):
pass
def trailing_comma2[
T = int
](a: str,):
pass My AssessmentI believe the following adjustments should be made to align with valid and consistent formatting:
def trailing_comma2[T = int](
a: str,
):
pass Am I correct in my assessment? |
Yes, that sounds right (assuming default settings, not |
Context:
python 3.12 new feature:
Example in the current Black style:
Enforcing black to wrap lines gives the ugly:
Desired style:
Additional context
python==3.12
black==23.11.0
Windows==11
VScode==1.84.2
VScode extension! Black Formatter==v2023.6.0
Credits:
Thank you for your great tool.
Patrick, Paris, France.
The text was updated successfully, but these errors were encountered: