basedmypy icon indicating copy to clipboard operation
basedmypy copied to clipboard

Allow shorthand `[T]` for `list[T]`, `{T}` for `set[T]`, and `{K: V}` for `dict[K, V]`

Open tmke8 opened this issue 1 year ago • 1 comments

There's already (T, U, V) for tuple[T, U, V] and I think what I wrote is all valid syntax, so I think these shorthands are kind of the obvious way to write these types.

xs: [int] = [3, 6, 1]

def f() -> {float}:
    return {4.5, 7.2}

def g(d: {str: int}):
    print(d)

tmke8 avatar Mar 04 '24 11:03 tmke8

Interesting idea. We will discuss it at the next design meeting.

  • Similar to: #449

KotlinIsland avatar Mar 11 '24 01:03 KotlinIsland