Describe the bug
When a single-argument function definition breaks across multiple lines, Black will add a trailing comma (after the argument) in some cases but not others.
To Reproduce
For example, given the following Black adds a trailing comma after the annotation on x in the first case, but not the second, third, or fourth:
# Black inserts a trailing comma after the first argument's annotation here.
def long_function_name_goes_here(
x: Callable[List[int]]
) -> Union[List[int], float, str, bytes, Tuple[int]]:
pass
# But not here, or in any of the below.
def long_function_name_goes_here(
x: Callable[[str, Any], int]
) -> Union[List[int], float, str, bytes, Tuple[int]]:
pass
def long_function_name_goes_here(
x: Callable[List[int, str]]
) -> Union[List[int], float, str, bytes, Tuple[int]]:
pass
def long_function_name_goes_here(
x: Callable[List[int], str]
) -> Union[List[int], float, str, bytes, Tuple[int]]:
pass
So the inclusion of the trailing comma seems to depend on the content of the annotation (but not its length). One observation: Black omits the trailing comma when the annotation itself contains a comma.
(Here's the same example in the playground.)
Describe the bug
When a single-argument function definition breaks across multiple lines, Black will add a trailing comma (after the argument) in some cases but not others.
To Reproduce
For example, given the following Black adds a trailing comma after the annotation on
xin the first case, but not the second, third, or fourth:So the inclusion of the trailing comma seems to depend on the content of the annotation (but not its length). One observation: Black omits the trailing comma when the annotation itself contains a comma.
(Here's the same example in the playground.)