sphinx/tests/typing_test_data.py
Alex Grönholm a1f6baaa81 Fix annotations formatting for plain typing.Callable
The typing.Callable class may be used without generic arguments, in which case it is equivalent to collections.abc.Callable.
2016-11-02 21:43:33 +02:00

66 lines
1.0 KiB
Python

from typing import List, TypeVar, Union, Callable, Tuple
from numbers import Integral
def f0(x: int, y: Integral) -> None:
pass
def f1(x: List[int]) -> List[int]:
pass
T = TypeVar('T')
T_co = TypeVar('T_co', covariant=True)
T_contra = TypeVar('T_contra', contravariant=True)
def f2(x: List[T], y: List[T_co], z: T) -> List[T_contra]:
pass
def f3(x: Union[str, Integral]) -> None:
pass
MyStr = str
def f4(x: 'MyStr', y: MyStr) -> None:
pass
def f5(x: int, *, y: str, z: str) -> None:
pass
def f6(x: int, *args, y: str, z: str) -> None:
pass
def f7(x: int = None, y: dict = {}) -> None:
pass
def f8(x: Callable[[int, str], int]) -> None:
# See https://github.com/ambv/typehinting/issues/149 for Callable[..., int]
pass
def f9(x: Callable) -> None:
pass
def f10(x: Tuple[int, str], y: Tuple[int, ...]) -> None:
pass
class CustomAnnotation:
def __repr__(self):
return 'CustomAnnotation'
def f11(x: CustomAnnotation(), y: 123) -> None:
pass