-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Closed
Labels
Description
Describe the bug
Black collapses lists in return type annotations onto one line, regardless of the "magic" trailing comma.
To Reproduce
For example, take this code:
@hl.generator(name="simplepyfn")
def SimplePyFn(
context: hl.GeneratorContext,
buffer_input: Buffer[UInt8, 2],
func_input: Buffer[Int32, 2],
float_arg: Scalar[Float32],
offset: int = 0,
) -> tuple[
Buffer[UInt8, 2],
Buffer[UInt8, 2],
]:
"""
... more code here ...
"""
And run it with these arguments:
$ black file.py --target-version py39
The resulting file contains:
@hl.generator(name="simplepyfn")
def SimplePyFn(
context: hl.GeneratorContext,
buffer_input: Buffer[UInt8, 2],
func_input: Buffer[Int32, 2],
float_arg: Scalar[Float32],
offset: int = 0,
) -> tuple[Buffer[UInt8, 2], Buffer[UInt8, 2],]:
"""
... more code here ...
"""
Expected behavior
I would have expected the code to either
- Not be reformatted due to the magic trailing comma (preferred)
- Have the trailing comma removed. (worse)
Environment
- Black's version:
black, 22.3.0 (compiled: yes)
- OS and Python version: Ubuntu 20.04.3 LTS (WSL), Python 3.8.10
mczudowski, KotlinIsland, DetachHead, achimnol, comfuture and 1 more