basedmypy
basedmypy copied to clipboard
new based syntax
stringizer will kill us, but anyway:
cpython compatible based syntax:
(str) > intfor callable syntax, annoyinglyastwont see the parens here"foo" | "bar"for string literals, will need to be a per module setting (also need a fallback option for forward refs #361)f"a_{int}"for template literals or w/e we call them
custom only based syntax:
def f[T: Overload[str, int]]():for constrained typesT: (str, int)is stupid(int=, /, *, foo: str=, **bar: str) -> intfullform callable syntax (=or=...for default?)
wish moment, how should tuple/dict/*args/**kwargs work:
tuple/*args
def f1(*args: tuple[int]): ...
f1(1, 2, 3)
def f2(*args: *int): ...
f2(1, 2, 3)
def f3(*args: (int, str)):
f3(1, "a")
v1: tuple[int] = 1, 2, 3
v2: *int = 1, 2, 3
v3: (int, str) = 1, "a"
edge case:
yeah: tuple[()] = (), (), ()
dict/**kwargs
would be similar and consistent:
def f1(**kwargs: dict[str, int]): ...
f1(a=1, b=2, c=3)
def f2(**kwargs: **int): ...
f2(a=1, b=2, c=3)
def f3(**kwargs: {"a": int}):
f3(a=1)
v1: dict[str, int] = {"a": 1, "b": 2, "c": 3}
v2: **int = {"a": 1, "b": 2, "c": 3}
v3: {"a": str} = {"a": 1}
edge case:
yeah: dict[str, {}] = {"a": {}, "b": {}, "c": {}}