Typing and Generics

typing.Type

A class object whose instances are compatible with T, rather than an instance of T. Deprecated typing alias; prefer type in modern code (3.9+).

Formal Syntax & Structure

python syntaxpython
typing.Type[T]

Return Value

type expression

Typing construct or runtime result as described; static typing rules are not runtime validation.

Working Example

Example Snippetpython
from typing import Type
class Base: passclass Child(Base): passdef create(cls: Type[Base]) -> Base: return cls()print(isinstance(create(Child),Child))
Python Reference