Python generic class definitions

E265439

Python generic class definitions are type-parameterized class constructs that enable writing reusable, type-safe classes using Python’s static type system.

All labels observed (1)

Label Occurrences
Python generic class definitions canonical 1

How this entity was disambiguated

Statements (49)

Predicate Object
instanceOf programming language feature ⓘ
type system construct ⓘ
allows parameterization over types ⓘ
canBe combined with inheritance ⓘ
nested ⓘ
specialized with concrete types at use sites ⓘ
checkedBy PyCharm type checker ⓘ
linked to: PyCharm

Pyre ⓘ
mypy ⓘ
pyright ⓘ
compatibleSinceVersion Python 3.5 ⓘ
linked to: Python 3.x
doesNotAffect runtime semantics by default ⓘ
enables reusable class definitions ⓘ
type-safe class design ⓘ
exampleWithPEP695 class Box[T]: ... ⓘ
formalizedIn PEP 560 ⓘ
PEP 695 ⓘ
goal catch type errors at development time ⓘ
reduce code duplication ⓘ
hasAlternativeSyntax PEP 695 type parameter list ⓘ
improves IDE autocompletion ⓘ
code readability ⓘ
static type checking precision ⓘ
interpretedBy static type checkers rather than Python runtime ⓘ
introducedIn PEP 484 ⓘ
oftenUses typing.Generic ⓘ
typing.ParamSpec ⓘ
typing.Protocol ⓘ
typing.TypeVar ⓘ
typing.TypeVarTuple ⓘ
partOf Python static type system ⓘ
linked to: PEP 484
relatedTo Python generics ⓘ
generic functions in Python ⓘ
typing.Annotated ⓘ
typing.Self ⓘ
requires typing module ⓘ
supports bounded type variables ⓘ
constraints on type variables ⓘ
generic base classes ⓘ
generic methods ⓘ
recursive type references ⓘ
type parameters ⓘ
variance annotations ⓘ
syntaxExample T = TypeVar('T') ⓘ
class Box(Generic[T]): ... ⓘ
usedFor APIs with type parameters ⓘ
collections ⓘ
data containers ⓘ
usedInLanguage Python ⓘ

How these facts were elicited

Referenced by (1)

Full triples — surface form annotated when it differs from this entity's canonical label.

PEP 695 → affects → Python generic class definitions ⓘ