Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
Public Member Functions | Static Protected Attributes | List of all members
pip._vendor.typing_extensions.TypeVarTuple Class Reference
Inheritance diagram for pip._vendor.typing_extensions.TypeVarTuple:
Inheritance graph
[legend]
Collaboration diagram for pip._vendor.typing_extensions.TypeVarTuple:
Collaboration graph
[legend]

Public Member Functions

 __new__ (cls, name, *default=_marker)
 
 __init_subclass__ (self, *args, **kwds)
 
 __iter__ (self)
 
 __init__ (self, name, *default=_marker)
 
 __repr__ (self)
 
 __hash__ (self)
 
 __eq__ (self, other)
 
 __reduce__ (self)
 
 __init_subclass__ (self, *args, **kwds)
 
- Public Member Functions inherited from pip._vendor.typing_extensions._TypeVarLikeMeta
bool __instancecheck__ (cls, Any __instance)
 

Static Protected Attributes

 _backported_typevarlike = typing.TypeVarTuple
 

Additional Inherited Members

- Protected Attributes inherited from pip._vendor.typing_extensions._TypeVarLikeMeta
 _backported_typevarlike
 

Detailed Description

Type variable tuple.
Type variable tuple.

Usage::

    Ts = TypeVarTuple('Ts')

In the same way that a normal type variable is a stand-in for a single
type such as ``int``, a type variable *tuple* is a stand-in for a *tuple*
type such as ``Tuple[int, str]``.

Type variable tuples can be used in ``Generic`` declarations.
Consider the following example::

    class Array(Generic[*Ts]): ...

The ``Ts`` type variable tuple here behaves like ``tuple[T1, T2]``,
where ``T1`` and ``T2`` are type variables. To use these type variables
as type parameters of ``Array``, we must *unpack* the type variable tuple using
the star operator: ``*Ts``. The signature of ``Array`` then behaves
as if we had simply written ``class Array(Generic[T1, T2]): ...``.
In contrast to ``Generic[T1, T2]``, however, ``Generic[*Shape]`` allows
us to parameterise the class with an *arbitrary* number of type parameters.

Type variable tuples can be used anywhere a normal ``TypeVar`` can.
This includes class definitions, as shown above, as well as function
signatures and variable annotations::

    class Array(Generic[*Ts]):

        def __init__(self, shape: Tuple[*Ts]):
            self._shape: Tuple[*Ts] = shape

        def get_shape(self) -> Tuple[*Ts]:
            return self._shape

    shape = (Height(480), Width(640))
    x: Array[Height, Width] = Array(shape)
    y = abs(x)  # Inferred type is Array[Height, Width]
    z = x + x   #        ...    is Array[Height, Width]
    x.get_shape()  #     ...    is tuple[Height, Width]

Constructor & Destructor Documentation

◆ __init__()

pip._vendor.typing_extensions.TypeVarTuple.__init__ (   self,
  name,
default = _marker 
)

The documentation for this class was generated from the following file: