]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-39481: Implementation for PEP 585 (#18239)
authorGuido van Rossum <guido@python.org>
Tue, 7 Apr 2020 16:50:06 +0000 (09:50 -0700)
committerGitHub <noreply@github.com>
Tue, 7 Apr 2020 16:50:06 +0000 (09:50 -0700)
commit48b069a003ba6c684a9ba78493fbbec5e89f10b8
treee67e71abd17516cea5fe1a1ec487bf929ab0b9fd
parent9cc3ebd7e04cb645ac7b2f372eaafa7464e16b9c
bpo-39481: Implementation for PEP 585 (#18239)

This implements things like `list[int]`,
which returns an object of type `types.GenericAlias`.
This object mostly acts as a proxy for `list`,
but has attributes `__origin__` and `__args__`
that allow recovering the parts (with values `list` and `(int,)`.

There is also an approximate notion of type variables;
e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`.
Type variables are objects of type `typing.TypeVar`.
30 files changed:
Include/Python.h
Include/genericaliasobject.h [new file with mode: 0644]
Lib/_collections_abc.py
Lib/contextlib.py
Lib/os.py
Lib/subprocess.py
Lib/tempfile.py
Lib/test/test_descrtut.py
Lib/test/test_doctest.py
Lib/test/test_genericalias.py [new file with mode: 0644]
Lib/test/test_os.py
Lib/test/test_subprocess.py
Lib/test/test_tempfile.py
Lib/test/test_types.py
Lib/test/test_typing.py
Lib/types.py
Lib/typing.py
Makefile.pre.in
Misc/NEWS.d/next/Core and Builtins/2020-01-28-17-19-18.bpo-39481.rqSeGl.rst [new file with mode: 0644]
Modules/_collectionsmodule.c
Modules/_sre.c
Objects/abstract.c
Objects/descrobject.c
Objects/dictobject.c
Objects/genericaliasobject.c [new file with mode: 0644]
Objects/listobject.c
Objects/setobject.c
Objects/tupleobject.c
PC/python3.def
PCbuild/pythoncore.vcxproj