| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
import pathlib |
| 4 |
from typing import TYPE_CHECKING, Tuple, TypeVar, Union # NoQA: UP035 |
| 5 |
|
| 6 |
if TYPE_CHECKING: |
| 7 |
from typing import Any |
| 8 |
|
| 9 |
CONST1: int |
| 10 |
#: docstring |
| 11 |
CONST2: int = 1 |
| 12 |
#: docstring |
| 13 |
CONST3: pathlib.PurePosixPath = pathlib.PurePosixPath('/a/b/c') |
| 14 |
#: docstring |
| 15 |
T = TypeVar('T', bound=pathlib.PurePosixPath) |
| 16 |
|
| 17 |
|
| 18 |
def incr(a: int, b: int = 1) -> int: |
| 19 |
return a + b |
| 20 |
|
| 21 |
|
| 22 |
def decr(a, b=1): |
| 23 |
# type: (int, int) -> int |
| 24 |
return a - b |
| 25 |
|
| 26 |
|
| 27 |
class Math: |
| 28 |
CONST1: int |
| 29 |
CONST2: int = 1 |
| 30 |
CONST3: pathlib.PurePosixPath = pathlib.PurePosixPath('/a/b/c') |
| 31 |
|
| 32 |
def __init__(self, s: str, o: Any = None) -> None: |
| 33 |
pass |
| 34 |
|
| 35 |
def incr(self, a: int, b: int = 1) -> int: |
| 36 |
return a + b |
| 37 |
|
| 38 |
def decr(self, a, b=1): |
| 39 |
# type: (int, int) -> int |
| 40 |
return a - b |
| 41 |
|
| 42 |
def nothing(self): |
| 43 |
# type: () -> None |
| 44 |
pass |
| 45 |
|
| 46 |
def horse( |
| 47 |
self, |
| 48 |
a, # type: str |
| 49 |
b, # type: int |
| 50 |
): |
| 51 |
# type: (...) -> None |
| 52 |
return |
| 53 |
|
| 54 |
@property |
| 55 |
def prop(self) -> int: |
| 56 |
return 0 |
| 57 |
|
| 58 |
@property |
| 59 |
def path(self) -> pathlib.PurePosixPath: |
| 60 |
return pathlib.PurePosixPath('/a/b/c') |
| 61 |
|
| 62 |
|
| 63 |
def tuple_args(x: tuple[int, int | str]) -> tuple[int, int]: |
| 64 |
pass |
| 65 |
|
| 66 |
|
| 67 |
class NewAnnotation: |
| 68 |
def __new__(cls, i: int) -> NewAnnotation: # NoQA: PYI034 |
| 69 |
pass |
| 70 |
|
| 71 |
|
| 72 |
class NewComment: |
| 73 |
def __new__(cls, i): |
| 74 |
# type: (int) -> NewComment |
| 75 |
pass |
| 76 |
|
| 77 |
|
| 78 |
class _MetaclassWithCall(type): |
| 79 |
def __call__(cls, a: int): |
| 80 |
pass |
| 81 |
|
| 82 |
|
| 83 |
class SignatureFromMetaclass(metaclass=_MetaclassWithCall): |
| 84 |
pass |
| 85 |
|
| 86 |
|
| 87 |
def complex_func(arg1, arg2, arg3=None, *args, **kwargs): |
| 88 |
# type: (str, List[int], Tuple[int, Union[str, Unknown]], *str, **str) -> None |
| 89 |
pass |
| 90 |
|
| 91 |
|
| 92 |
def missing_attr( |
| 93 |
c, |
| 94 |
a, # type: str |
| 95 |
b=None, # type: Optional[str] |
| 96 |
): |
| 97 |
# type: (...) -> str |
| 98 |
return a + (b or '') |
| 99 |
|
| 100 |
|
| 101 |
class _ClassWithDocumentedInit: |
| 102 |
"""Class docstring.""" |
| 103 |
|
| 104 |
def __init__(self, x: int, *args: int, **kwargs: int) -> None: |
| 105 |
"""Init docstring. |
| 106 |
|
| 107 |
:param x: Some integer |
| 108 |
:param args: Some integer |
| 109 |
:param kwargs: Some integer |
| 110 |
""" |