You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"More concise formatting for dummy implementations" can be less conciseΒ #3872
This would only happen if the signature is within a few characters of the requested line length. It's a little unfortunate, but I think it's better to stay consistent with other signatures and accept this behavior.
Yup, what Jelle said. When writing the patch I thought this would be fairly uncommon. I'll leave this issue open since this is still in preview style and maybe this is much more common than I anticipated. But as it stands, this is a won't fix. Black generally prefers fewer, consistent rules.
This is actually something I've noticed quite a few times when it comes to black's formatting of typeshed's stubs, so I don't think it's that uncommon. I quite like @bersbersbers's suggestion of allowing ... on a line of its own if appending it to the previous line leads to line breaks.
Having said that, we've had the current formatting rules in typeshed for a long time, and it's not hugely ugly; I don't think this should be a high-priority issue!
I still think we should stick with the current behavior. With the proposed change, we'd have this sequence:
# A short function name has ... right after the : defshort(param, another_one) ->ReturnType: ...
# A medium-length one has it on its own linedeflong_function_with_sine_params_and_long_return(param, another_one) ->ReturnType:
...
# With an even longer one, it goes back to right after the colon:deflong_function_with_sine_params_and_long_return(
param: some_type, another_one: some_type
) ->ReturnType: ...
With the current behavior, the ... instead always stays in the same place. I think that's better, even if it occasionally means more lines.
In #4063 I originally tried to make it so ellipses with comments didn't count as dummy implementations, but that also caused problems because it changed formatting in stubs.
This case seems more obviously bad, and maybe it's enough to justify backing out the dummy implementation change. Or we could add some special casing around comments in non-stub files, but that also feels unprincipled.
Note that example doesn't repro as-is; you need a shorter line length or longer args or longer comment (and IMO it looks a little less bad if so)
I think it's not worth backing out the change. #1797 was a pretty popular issue. This is probably the second biggest upgrade for me in 2024 style (first place being #2316). But given that this has been reported twice, it would be nice if we could still see diff-shades from this change
Activity
JelleZijlstra commentedon Sep 10, 2023
This would only happen if the signature is within a few characters of the requested line length. It's a little unfortunate, but I think it's better to stay consistent with other signatures and accept this behavior.
hauntsaninja commentedon Sep 11, 2023
Yup, what Jelle said. When writing the patch I thought this would be fairly uncommon. I'll leave this issue open since this is still in preview style and maybe this is much more common than I anticipated. But as it stands, this is a won't fix. Black generally prefers fewer, consistent rules.
AlexWaygood commentedon Sep 13, 2023
This is actually something I've noticed quite a few times when it comes to black's formatting of typeshed's stubs, so I don't think it's that uncommon. I quite like @bersbersbers's suggestion of allowing
...on a line of its own if appending it to the previous line leads to line breaks.Having said that, we've had the current formatting rules in typeshed for a long time, and it's not hugely ugly; I don't think this should be a high-priority issue!
JelleZijlstra commentedon Oct 28, 2023
I still think we should stick with the current behavior. With the proposed change, we'd have this sequence:
With the current behavior, the
...instead always stays in the same place. I think that's better, even if it occasionally means more lines.JelleZijlstra commentedon Jan 11, 2024
#4042 (comment) brought up a related case that makes us more likely to output less concise formatting: if there is a comment after the
....In #4063 I originally tried to make it so ellipses with comments didn't count as dummy implementations, but that also caused problems because it changed formatting in stubs.
This case seems more obviously bad, and maybe it's enough to justify backing out the dummy implementation change. Or we could add some special casing around comments in non-stub files, but that also feels unprincipled.
hauntsaninja commentedon Jan 11, 2024
Note that example doesn't repro as-is; you need a shorter line length or longer args or longer comment (and IMO it looks a little less bad if so)
I think it's not worth backing out the change. #1797 was a pretty popular issue. This is probably the second biggest upgrade for me in 2024 style (first place being #2316). But given that this has been reported twice, it would be nice if we could still see diff-shades from this change