PyDocs

Nav

Python Language Services

TypeVar

ast

class · Added in 3.12
  • TypeVar(name, bound, default_value)
TypeVar(identifier name, expr? bound, expr? default_value)
Changed in 3.13
  • 3.13: Added the default_value parameter.
1 Example
>>> print(ast.dump(ast.parse("type Alias[T: int = bool] = list[T]"), indent=4))
Module(
    body=[
        TypeAlias(
            name=Name(id='Alias', ctx=Store()),
            type_params=[
                TypeVar(
                    name='T',
                    bound=Name(id='int'),
                    default_value=Name(id='bool'))],
            value=Subscript(
                value=Name(id='list'),
                slice=Name(id='T')))])
from the Python docs
See Also
No see-alsos for ast/TypeVar
0 Notes
No notes for TypeVar