@@ -2109,6 +2109,30 @@ without the dedicated syntax, as documented below.
21092109
21102110 .. versionadded :: 3.15
21112111
2112+ .. attribute :: __bound__
2113+
2114+ The upper bound of each of the types the type variable tuple stands for,
2115+ if any.
2116+
2117+ .. versionchanged :: 3.16
2118+
2119+ For type variable tuples created through
2120+ :ref: `type parameter syntax <type-params >`, the bound is evaluated only
2121+ when the attribute is accessed, not when the type variable tuple is
2122+ created (see :ref: `lazy-evaluation `).
2123+
2124+ .. method :: evaluate_bound
2125+
2126+ An :term: `evaluate function ` corresponding to the
2127+ :attr: `~TypeVarTuple.__bound__ ` attribute.
2128+ When called directly, this method supports only the :attr: `~annotationlib.Format.VALUE `
2129+ format, which is equivalent to accessing the :attr: `~TypeVarTuple.__bound__ ` attribute
2130+ directly, but the method object can be passed to
2131+ :func: `annotationlib.call_evaluate_function ` to evaluate the value in a
2132+ different format.
2133+
2134+ .. versionadded :: 3.16
2135+
21122136 .. attribute :: __default__
21132137
21142138 The default value of the type variable tuple, or :data: `typing.NoDefault ` if it
@@ -2135,11 +2159,6 @@ without the dedicated syntax, as documented below.
21352159
21362160 .. versionadded :: 3.13
21372161
2138- Type variable tuples created with ``covariant=True `` or
2139- ``contravariant=True `` can be used to declare covariant or contravariant
2140- generic types. The ``bound `` argument is also accepted, similar to
2141- :class: `TypeVar `, but its actual semantics are yet to be decided.
2142-
21432162 .. versionadded :: 3.11
21442163
21452164 .. versionchanged :: 3.12
@@ -2156,6 +2175,12 @@ without the dedicated syntax, as documented below.
21562175 Added support for the ``bound ``, ``covariant ``, ``contravariant ``, and
21572176 ``infer_variance `` parameters.
21582177
2178+ .. versionchanged :: 3.16
2179+
2180+ Type variable tuple bounds can now be declared using the
2181+ :ref: `type parameter <type-params >` syntax, and are
2182+ :ref: `lazily evaluated <lazy-evaluation >`.
2183+
21592184.. class :: ParamSpec(name, *, bound=None, covariant=False, contravariant=False, infer_variance=False, default=typing.NoDefault)
21602185
21612186 Parameter specification variable. A specialized version of
@@ -2239,6 +2264,34 @@ without the dedicated syntax, as documented below.
22392264
22402265 .. versionadded :: 3.12
22412266
2267+ .. attribute :: __bound__
2268+
2269+ The upper bound of the parameter specification, if any. Because a
2270+ parameter specification stands for the parameters of a callable, its
2271+ bound is a parameter list, such as ``[int, str] ``.
2272+
2273+ .. versionchanged :: 3.16
2274+
2275+ For parameter specifications created through
2276+ :ref: `type parameter syntax <type-params >`, the bound is evaluated only
2277+ when the attribute is accessed, not when the parameter specification is
2278+ created (see :ref: `lazy-evaluation `).
2279+
2280+ Previously, :attr: `!__bound__ ` was :class: `types.NoneType ` rather than
2281+ ``None `` when no bound was given.
2282+
2283+ .. method :: evaluate_bound
2284+
2285+ An :term: `evaluate function ` corresponding to the
2286+ :attr: `~ParamSpec.__bound__ ` attribute.
2287+ When called directly, this method supports only the :attr: `~annotationlib.Format.VALUE `
2288+ format, which is equivalent to accessing the :attr: `~ParamSpec.__bound__ ` attribute
2289+ directly, but the method object can be passed to
2290+ :func: `annotationlib.call_evaluate_function ` to evaluate the value in a
2291+ different format.
2292+
2293+ .. versionadded :: 3.16
2294+
22422295 .. attribute :: __default__
22432296
22442297 The default value of the parameter specification, or :data: `typing.NoDefault ` if it
@@ -2267,8 +2320,7 @@ without the dedicated syntax, as documented below.
22672320
22682321 Parameter specification variables created with ``covariant=True `` or
22692322 ``contravariant=True `` can be used to declare covariant or contravariant
2270- generic types. The ``bound `` argument is also accepted, similar to
2271- :class: `TypeVar `. However the actual semantics of these keywords are yet to
2323+ generic types. However the actual semantics of these keywords are yet to
22722324 be decided.
22732325
22742326 .. versionadded :: 3.10
@@ -2282,6 +2334,12 @@ without the dedicated syntax, as documented below.
22822334
22832335 Support for default values was added.
22842336
2337+ .. versionchanged :: 3.16
2338+
2339+ Parameter specification bounds can now be declared using the
2340+ :ref: `type parameter <type-params >` syntax, and are
2341+ :ref: `lazily evaluated <lazy-evaluation >`.
2342+
22852343 .. note ::
22862344 Only parameter specification variables defined in global scope can
22872345 be pickled.
0 commit comments