Skip to content

bagof.hints.typevars.infer

TypeVars with inferred variance.

These are declared with infer_variance=True, so the variance is not fixed up front: the type checker derives it for each generic class separately, from how the class actually uses the parameter. That makes a single TypeVar reusable across classes that would otherwise need the covariant, contravariant and invariant flavours.

Variance is only ever inferred per generic class or protocol definition; it says nothing about the TypeVar in isolation.

Every TypeVar here carries an upper bound (not a set of value constraints), so it can be solved for any subtype of that bound, and never for an unrelated type.

Attributes

K module-attribute

K = tx.TypeVar('K', bound=tx.Hashable, infer_variance=True)

An inferred-variance TypeVar for hashable objects (with a compact name).

T module-attribute

T = tx.TypeVar('T', default=tx.Any, infer_variance=True)

An inferred-variance TypeVar (with a compact name).

OBJECT module-attribute

OBJECT = tx.TypeVar('OBJECT', infer_variance=True, bound=object)

An inferred-variance TypeVar for objects.

TYPE module-attribute

TYPE = tx.TypeVar('TYPE', infer_variance=True, bound=type)

An inferred-variance TypeVar for types.

NONE module-attribute

NONE = tx.TypeVar('NONE', infer_variance=True, bound=NoneType)

An inferred-variance TypeVar for None values.

STR module-attribute

STR = tx.TypeVar('STR', infer_variance=True, bound=str)

An inferred-variance TypeVar for strings.

BYTES module-attribute

BYTES = tx.TypeVar('BYTES', infer_variance=True, bound=bytes)

An inferred-variance TypeVar for bytes.

BOOL module-attribute

BOOL = tx.TypeVar('BOOL', infer_variance=True, bound=bool)

An inferred-variance TypeVar for booleans.

INT module-attribute

INT = tx.TypeVar('INT', infer_variance=True, bound=int)

An inferred-variance TypeVar for (builtin) ints.

FLOAT module-attribute

FLOAT = tx.TypeVar('FLOAT', infer_variance=True, bound=float)

An inferred-variance TypeVar for (builtin) floats.

COMPLEX module-attribute

COMPLEX = tx.TypeVar('COMPLEX', infer_variance=True, bound=complex)

An inferred-variance TypeVar for (builtin) complex numbers.

INTEGRAL module-attribute

INTEGRAL = tx.TypeVar('INTEGRAL', infer_variance=True, bound=numbers.Integral)

An inferred-variance TypeVar for integral numbers.

REAL module-attribute

REAL = tx.TypeVar('REAL', infer_variance=True, bound=numbers.Real)

An inferred-variance TypeVar for real numbers.

NUMBER module-attribute

NUMBER = tx.TypeVar('NUMBER', infer_variance=True, bound=numbers.Number)

An inferred-variance TypeVar for numeric values.

CONTAINER module-attribute

CONTAINER = tx.TypeVar('CONTAINER', infer_variance=True, bound=tx.Container[tx.Any])

An inferred-variance TypeVar for containers.

HASHABLE module-attribute

HASHABLE = tx.TypeVar('HASHABLE', infer_variance=True, bound=tx.Hashable)

An inferred-variance TypeVar for hashable objects.

ITERABLE module-attribute

ITERABLE = tx.TypeVar('ITERABLE', infer_variance=True, bound=tx.Iterable[tx.Any])

An inferred-variance TypeVar for iterables.

ITERATOR module-attribute

ITERATOR = tx.TypeVar('ITERATOR', infer_variance=True, bound=tx.Iterator[tx.Any])

An inferred-variance TypeVar for iterators.

REVERSIBLE module-attribute

REVERSIBLE = tx.TypeVar('REVERSIBLE', infer_variance=True, bound=tx.Reversible[tx.Any])

An inferred-variance TypeVar for reversibles.

GENERATOR module-attribute

GENERATOR = tx.TypeVar('GENERATOR', infer_variance=True, bound=tx.Generator[tx.Any, tx.Any, tx.Any])

An inferred-variance TypeVar for generators.

SIZED module-attribute

SIZED = tx.TypeVar('SIZED', infer_variance=True, bound=tx.Sized)

An inferred-variance TypeVar for sized objects.

COLLECTION module-attribute

COLLECTION = tx.TypeVar('COLLECTION', infer_variance=True, bound=tx.Collection[tx.Any])

An inferred-variance TypeVar for collections.

SEQUENCE module-attribute

SEQUENCE = tx.TypeVar('SEQUENCE', infer_variance=True, bound=tx.Sequence[tx.Any])

An inferred-variance TypeVar for sequences.

MUTABLE_SEQUENCE module-attribute

MUTABLE_SEQUENCE = tx.TypeVar('MUTABLE_SEQUENCE', infer_variance=True, bound=tx.MutableSequence[tx.Any])

An inferred-variance TypeVar for mutable sequences.

SET module-attribute

SET = tx.TypeVar('SET', infer_variance=True, bound=tx.Set[tx.Any])

An inferred-variance TypeVar for sets.

MUTABLE_SET module-attribute

MUTABLE_SET = tx.TypeVar('MUTABLE_SET', infer_variance=True, bound=tx.MutableSet[tx.Any])

An inferred-variance TypeVar for mutable sets.

MAPPING module-attribute

MAPPING = tx.TypeVar('MAPPING', infer_variance=True, bound=tx.Mapping[tx.Any, tx.Any])

An inferred-variance TypeVar for mappings.

MUTABLE_MAPPING module-attribute

MUTABLE_MAPPING = tx.TypeVar('MUTABLE_MAPPING', infer_variance=True, bound=tx.MutableMapping[tx.Any, tx.Any])

An inferred-variance TypeVar for mutable mappings.

AWAITABLE module-attribute

AWAITABLE = tx.TypeVar('AWAITABLE', infer_variance=True, bound=tx.Awaitable[tx.Any])

An inferred-variance TypeVar for awaitables.

BUFFER module-attribute

BUFFER = tx.TypeVar('BUFFER', infer_variance=True, bound=tx.Buffer)

An inferred-variance TypeVar for buffers.

LIST module-attribute

LIST = tx.TypeVar('LIST', infer_variance=True, bound=tx.List[tx.Any])

An inferred-variance TypeVar for lists.

TUPLE module-attribute

TUPLE = tx.TypeVar('TUPLE', infer_variance=True, bound=tx.Tuple[tx.Any, ...])

An inferred-variance TypeVar for tuples.

DICT module-attribute

DICT = tx.TypeVar('DICT', infer_variance=True, bound=tx.Dict[tx.Any, tx.Any])

An inferred-variance TypeVar for dictionaries.