| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
from typing import TYPE_CHECKING, overload |
| 4 |
|
| 5 |
if TYPE_CHECKING: |
| 6 |
from typing import Any |
| 7 |
|
| 8 |
|
| 9 |
@overload |
| 10 |
def sum(x: int, y: int = 0) -> int: ... |
| 11 |
|
| 12 |
|
| 13 |
@overload |
| 14 |
def sum(x: float, y: float = 0.0) -> float: ... |
| 15 |
|
| 16 |
|
| 17 |
@overload |
| 18 |
def sum(x: str, y: str = ...) -> str: ... |
| 19 |
|
| 20 |
|
| 21 |
def sum(x, y=None): |
| 22 |
"""docstring""" |
| 23 |
return x + y |
| 24 |
|
| 25 |
|
| 26 |
class Math: |
| 27 |
"""docstring""" |
| 28 |
|
| 29 |
@overload |
| 30 |
def sum(self, x: int, y: int = 0) -> int: ... |
| 31 |
|
| 32 |
@overload |
| 33 |
def sum(self, x: float, y: float = 0.0) -> float: ... |
| 34 |
|
| 35 |
@overload |
| 36 |
def sum(self, x: str, y: str = ...) -> str: ... |
| 37 |
|
| 38 |
def sum(self, x, y=None): |
| 39 |
"""docstring""" |
| 40 |
return x + y |
| 41 |
|
| 42 |
|
| 43 |
class Foo: |
| 44 |
"""docstring""" |
| 45 |
|
| 46 |
@overload |
| 47 |
def __new__(cls, x: int, y: int) -> Foo: ... |
| 48 |
|
| 49 |
@overload |
| 50 |
def __new__(cls, x: str, y: str) -> Foo: ... |
| 51 |
|
| 52 |
def __new__(cls, x, y): |
| 53 |
pass |
| 54 |
|
| 55 |
|
| 56 |
class Bar: |
| 57 |
"""docstring""" |
| 58 |
|
| 59 |
@overload |
| 60 |
def __init__(self, x: int, y: int) -> None: ... |
| 61 |
|
| 62 |
@overload |
| 63 |
def __init__(self, x: str, y: str) -> None: ... |
| 64 |
|
| 65 |
def __init__(self, x, y): |
| 66 |
pass |
| 67 |
|
| 68 |
|
| 69 |
class Meta(type): |
| 70 |
@overload |
| 71 |
def __call__(cls, x: int, y: int) -> Any: ... |
| 72 |
|
| 73 |
@overload |
| 74 |
def __call__(cls, x: str, y: str) -> Any: ... |
| 75 |
|
| 76 |
def __call__(cls, x, y): |
| 77 |
pass |
| 78 |
|
| 79 |
|
| 80 |
class Baz(metaclass=Meta): |
| 81 |
"""docstring""" |