Skip to content

PEP 484 - comment-based type annotations examples

PEP 484 - Type Hints

Handsdown API Index / Examples / PEP 484 - comment-based type annotations examples

Auto-generated documentation for examples.comment_typed module.

MyValue

Show source in comment_typed.py:11

Signature

class MyValue:
    def __init__(self, *args, **kwargs) -> None:
        ...

Typed

Show source in comment_typed.py:17

Attributes

  • two - comment here: 2

Signature

class Typed:
    def __init__(
        self,
        my_bool: bool = one & ~two == "three" and not -4,
        my_lambda=lambda x, y, *args, **kwargs,: x + y,
        my_set: Set = {1, 2, [3, 4], {5: 6}, (7, 8)},
        _value: Union[List[str], str, MyValue] = MyValue(
            "asd", *args, kwarg=123, **extras
        ),
        _name: str = "default",
    ) -> None:
        ...

See also

Typed.classmethod

Show source in comment_typed.py:36

Signature

@classmethod
def classmethod(cls, _my_value: MyValue, *_args: str, **_kwargs: Any) -> Typed:
    ...

See also

func

Show source in comment_typed.py:42

Signature

def func(
    _list: Tuple[List[str], ...], _my_value_cls: Type[MyValue] = MyValue, **_kwargs: None
) -> Any:
    ...

See also

func_any

Show source in comment_typed.py:47

Signature

def func_any(
    _list: Tuple[List[str], ...], _my_value_cls: Any = MyValue, **_kwargs: None
) -> Any:
    ...

See also