2020-05-31 12:08:57 -05:00
|
|
|
from __future__ import annotations
|
2022-12-30 14:14:18 -06:00
|
|
|
|
2025-01-13 15:56:36 -06:00
|
|
|
from typing import TYPE_CHECKING, overload
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from typing import Any
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def sum(x: int, y: int = 0) -> int: ...
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def sum(x: float, y: float = 0.0) -> float: ...
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def sum(x: str, y: str = ...) -> str: ...
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
|
2021-01-16 10:14:28 -06:00
|
|
|
def sum(x, y=None):
|
2020-05-24 09:34:09 -05:00
|
|
|
"""docstring"""
|
|
|
|
return x + y
|
|
|
|
|
|
|
|
|
|
|
|
class Math:
|
|
|
|
"""docstring"""
|
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def sum(self, x: int, y: int = 0) -> int: ...
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def sum(self, x: float, y: float = 0.0) -> float: ...
|
2020-05-24 09:34:09 -05:00
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def sum(self, x: str, y: str = ...) -> str: ...
|
2020-05-24 09:34:09 -05:00
|
|
|
|
2021-01-16 10:14:28 -06:00
|
|
|
def sum(self, x, y=None):
|
2020-05-24 09:34:09 -05:00
|
|
|
"""docstring"""
|
|
|
|
return x + y
|
2020-05-31 12:08:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
class Foo:
|
|
|
|
"""docstring"""
|
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06:00
|
|
|
def __new__(cls, x: int, y: int) -> Foo: ...
|
2020-05-31 12:08:57 -05:00
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06: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
|
2025-01-02 19:09:26 -06:00
|
|
|
def __init__(cls, x: int, y: int) -> None: ...
|
2020-05-31 12:08:57 -05:00
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06: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
|
2025-01-02 19:09:26 -06:00
|
|
|
def __call__(cls, x: int, y: int) -> Any: ...
|
2020-05-31 12:08:57 -05:00
|
|
|
|
|
|
|
@overload
|
2025-01-02 19:09:26 -06: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"""
|