2020-05-31 12:08:57 -05:00
|
|
|
from typing import Any, overload
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
@overload
|
2021-01-16 10:50:31 -06:00
|
|
|
def sum(x: int, y: int = 0) -> int:
|
2020-05-24 09:34:09 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
@overload
|
2021-01-16 10:50:31 -06:00
|
|
|
def sum(x: "float", y: "float" = 0.0) -> "float":
|
2020-05-24 09:34:09 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
@overload
|
2021-01-16 10:50:31 -06:00
|
|
|
def sum(x: str, y: str = ...) -> str:
|
2020-05-24 09:34:09 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
|
|
|
|
def sum(x, y):
|
|
|
|
"""docstring"""
|
|
|
|
return x + y
|
|
|
|
|
|
|
|
|
|
|
|
class Math:
|
|
|
|
"""docstring"""
|
|
|
|
|
|
|
|
@overload
|
2021-01-16 10:50:31 -06:00
|
|
|
def sum(self, x: int, y: int = 0) -> int:
|
2020-05-24 09:34:09 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
@overload
|
2021-01-16 10:50:31 -06:00
|
|
|
def sum(self, x: "float", y: "float" = 0.0) -> "float":
|
2020-05-24 09:34:09 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
@overload
|
2021-01-16 10:50:31 -06:00
|
|
|
def sum(self, x: str, y: str = ...) -> str:
|
2020-05-24 09:34:09 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
def sum(self, x, y):
|
|
|
|
"""docstring"""
|
|
|
|
return x + y
|
2020-05-31 12:08:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
class Foo:
|
|
|
|
"""docstring"""
|
|
|
|
|
|
|
|
@overload
|
|
|
|
def __new__(cls, x: int, y: int) -> "Foo":
|
|
|
|
...
|
|
|
|
|
|
|
|
@overload
|
2020-07-10 22:10:07 -05:00
|
|
|
def __new__(cls, x: "str", y: "str") -> "Foo":
|
2020-05-31 12:08:57 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
def __new__(cls, x, y):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Bar:
|
|
|
|
"""docstring"""
|
|
|
|
|
|
|
|
@overload
|
|
|
|
def __init__(cls, x: int, y: int) -> None:
|
|
|
|
...
|
|
|
|
|
|
|
|
@overload
|
2020-07-10 22:10:07 -05:00
|
|
|
def __init__(cls, x: "str", y: "str") -> "None":
|
2020-05-31 12:08:57 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
def __init__(cls, x, y):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Meta(type):
|
|
|
|
@overload
|
|
|
|
def __call__(cls, x: int, y: int) -> Any:
|
|
|
|
...
|
|
|
|
|
|
|
|
@overload
|
2020-07-10 22:10:07 -05:00
|
|
|
def __call__(cls, x: "str", y: "str") -> "Any":
|
2020-05-31 12:08:57 -05:00
|
|
|
...
|
|
|
|
|
|
|
|
def __call__(cls, x, y):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Baz(metaclass=Meta):
|
|
|
|
"""docstring"""
|