Skip to content

bagof.hints.typevars.contra

Contravariant TypeVars.

A contravariant parameter reverses the subtype relation of its argument: since bool is a subtype of int, Consumer[int] is a subtype of Consumer[bool] and is usable wherever the latter is expected. That is only sound when the parameter appears in input ("consumer") positions alone -- parameter types, write-only attributes. A generic class that also hands the parameter back out must use an invariant TypeVar instead.

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', contravariant=True, bound=tx.Hashable)

A contravariant TypeVar for hashable objects (with a compact name).

T module-attribute

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

A contravariant TypeVar (with a compact name).

OBJECT module-attribute

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

A contravariant TypeVar for objects.

TYPE module-attribute

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

A contravariant TypeVar for types.

NONE module-attribute

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

A contravariant TypeVar for None values.

STR module-attribute

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

A contravariant TypeVar for strings.

BYTES module-attribute

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

A contravariant TypeVar for bytes.

BOOL module-attribute

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

A contravariant TypeVar for booleans.

INT module-attribute

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

A contravariant TypeVar for (builtin) ints.

FLOAT module-attribute

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

A contravariant TypeVar for (builtin) floats.

COMPLEX module-attribute

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

A contravariant TypeVar for (builtin) complex numbers.

INTEGRAL module-attribute

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

A contravariant TypeVar for integral numbers.

REAL module-attribute

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

A contravariant TypeVar for real numbers.

NUMBER module-attribute

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

A contravariant TypeVar for numeric values.

CONTAINER module-attribute

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

A contravariant TypeVar for containers.

HASHABLE module-attribute

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

A contravariant TypeVar for hashable objects.

ITERABLE module-attribute

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

A contravariant TypeVar for iterables.

ITERATOR module-attribute

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

A contravariant TypeVar for iterators.

REVERSIBLE module-attribute

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

A contravariant TypeVar for reversibles.

GENERATOR module-attribute

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

A contravariant TypeVar for generators.

SIZED module-attribute

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

A contravariant TypeVar for sized objects.

COLLECTION module-attribute

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

A contravariant TypeVar for collections.

SEQUENCE module-attribute

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

A contravariant TypeVar for sequences.

MUTABLE_SEQUENCE module-attribute

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

A contravariant TypeVar for mutable sequences.

SET module-attribute

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

A contravariant TypeVar for sets.

MUTABLE_SET module-attribute

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

A contravariant TypeVar for mutable sets.

MAPPING module-attribute

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

A contravariant TypeVar for mappings.

MUTABLE_MAPPING module-attribute

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

A contravariant TypeVar for mutable mappings.

AWAITABLE module-attribute

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

A contravariant TypeVar for awaitables.

BUFFER module-attribute

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

A contravariant TypeVar for buffers.

LIST module-attribute

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

A contravariant TypeVar for lists.

TUPLE module-attribute

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

A contravariant TypeVar for tuples.

DICT module-attribute

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

A contravariant TypeVar for dictionaries.