Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-116126: Implement PEP 696#116129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-116126: Implement PEP 696#116129
Changes from1 commit
e7ca092828679ed3b472b6e467eefa4858049b077b5cfd5e201b32707a69204a2650080c282978aa5b27bdd01bb2c28b9ab0d467fd7e91e235226b42e079eee0370527b15f1111bd102c54aeed71a348b900cd40c13420b8a08c62613159f4e0435e7d54ace12581d82b5a102a2c48c929b9435326de176f667757efa4ce29ad8432c04c147d4f3fd1a143675890d7919a7b48ef0616b9d4e8422686b9798d1decfbb6405e0ccfeb15aaff986f5aed3e0c0fcf5a3d4b92ea1085f6fdfdb3f053c8c3e0b4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1798,23 +1798,25 @@ Type parameters | ||
| :ref:`Type parameters <type-params>` can exist on classes, functions, and type | ||
| aliases. | ||
| .. class:: TypeVar(name, bound, default_value) | ||
| A :class:`typing.TypeVar`. ``name`` is the name of the type variable. | ||
| ``bound`` is the bound or constraints, if any. If ``bound`` is a :class:`Tuple`, | ||
| it represents constraints; otherwise it represents the bound. ``default_value`` | ||
| is the default value, if any. | ||
JelleZijlstra marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. doctest:: | ||
| >>> print(ast.dump(ast.parse("type Alias[T: int = bool] = list[T]"), indent=4)) | ||
| Module( | ||
| body=[ | ||
| TypeAlias( | ||
| name=Name(id='Alias', ctx=Store()), | ||
| type_params=[ | ||
| TypeVar( | ||
| name='T', | ||
| bound=Name(id='int', ctx=Load()), | ||
| default_value=Name(id='bool', ctx=Load()))], | ||
| value=Subscript( | ||
| value=Name(id='list', ctx=Load()), | ||
| slice=Name(id='T', ctx=Load()), | ||
| @@ -1823,19 +1825,28 @@ aliases. | ||
| .. versionadded:: 3.12 | ||
| .. versionchanged:: 3.13 | ||
| Added ``default_value``. | ||
JelleZijlstra marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. class:: ParamSpec(name, default_value) | ||
| A :class:`typing.ParamSpec`. ``name`` is the name of the parameter specification. | ||
| ``default_value`` is the default value, if any. | ||
| .. doctest:: | ||
| >>> print(ast.dump(ast.parse("type Alias[**P = (int, str)] = Callable[P, int]"), indent=4)) | ||
| Module( | ||
| body=[ | ||
| TypeAlias( | ||
| name=Name(id='Alias', ctx=Store()), | ||
| type_params=[ | ||
| ParamSpec(name='P', | ||
| default_value=Tuple( | ||
| elts=[ | ||
| Name(id='int', ctx=Load()), | ||
| Name(id='str', ctx=Load())], | ||
| ctx=Load()))], | ||
| value=Subscript( | ||
| value=Name(id='Callable', ctx=Load()), | ||
| slice=Tuple( | ||
| @@ -1848,19 +1859,24 @@ aliases. | ||
| .. versionadded:: 3.12 | ||
| .. versionchanged:: 3.13 | ||
| Added ``default_value``. | ||
JelleZijlstra marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. class:: TypeVarTuple(name) | ||
| A :class:`typing.TypeVarTuple`. ``name`` is the name of the type variable tuple. | ||
| ``default_value`` is the default value, if any. | ||
JelleZijlstra marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| .. doctest:: | ||
| >>> print(ast.dump(ast.parse("type Alias[*Ts = ()] = tuple[*Ts]"), indent=4)) | ||
| Module( | ||
| body=[ | ||
| TypeAlias( | ||
| name=Name(id='Alias', ctx=Store()), | ||
| type_params=[ | ||
| TypeVarTuple(name='Ts', | ||
| default_value=Tuple(elts=[], ctx=Load()))], | ||
| value=Subscript( | ||
| value=Name(id='tuple', ctx=Load()), | ||
| slice=Tuple( | ||
| @@ -1874,6 +1890,9 @@ aliases. | ||
| .. versionadded:: 3.12 | ||
| .. versionchanged:: 3.13 | ||
| Added ``default_value``. | ||
JelleZijlstra marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| Function and class definitions | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||