summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.11] [3.12] gh-112618: Make Annotated cache typed (GH-112619) (GH-112628) ↵Miss Islington (bot)2023-12-031-0/+34
| | | | | | | | (#112633) [3.12] gh-112618: Make Annotated cache typed (GH-112619) (GH-112628) (cherry picked from commit 2a378ca2efcb91db4b04fb4e052424fd610ffbc9) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.11] gh-112509: Fix keys being present in both required_keys and ↵Miss Islington (bot)2023-11-291-0/+40
| | | | | | | | optional_keys in TypedDict (GH-112512) (#112531) (cherry picked from commit 403886942376210662610627b01fea6acd77d331) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.11] gh-112155: Run `typing.py` doctests during tests (GH-112156) (#112231)Nikita Sobolev2023-11-181-0/+6
|
* [3.11] gh-108303: Move more typing related files to Lib/test/typinganndata ↵Nikita Sobolev2023-11-081-2/+1
| | | | (GH-111825) (#111860)
* [3.11] gh-111126: Use `isinstance` instead of `assert[Not]IsInstance` in ↵Miss Islington (bot)2023-10-201-4/+4
| | | | | | | | `test_typing` (GH-111127) (#111131) gh-111126: Use `isinstance` instead of `assert[Not]IsInstance` in `test_typing` (GH-111127) (cherry picked from commit ea7c26e4b89c71234c4a603567a93f0a44c9cc97) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] Enable ruff on `Lib/test/test_typing.py` (#110179) (#110290)Alex Waygood2023-10-031-40/+40
|
* [3.11] gh-108303: Move `ann_module*.py` files to `typinganndata/` folder ↵Victor Stinner2023-09-211-2/+4
| | | | | | | | | (#108354) (#109673) gh-108303: Move `ann_module*.py` files to `typinganndata/` folder (#108354) (cherry picked from commit 3f61cf646d0506baa0c0c2118f05110446519c62) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] gh-105834: Backport new tests for `typing.Protocol` (#105835) (#105860)Alex Waygood2023-06-161-0/+99
|
* [3.11] gh-103171: Revert undocumented behaviour change for runtime-checkable ↵Alex Waygood2023-06-071-0/+65
| | | | protocols decorated with `@final` (#105445)
* [3.11] Remove raw asserts in test_typing.py (GH-104951) (#104979)Miss Islington (bot)2023-05-261-22/+30
| | | | | | Remove raw asserts in test_typing.py (GH-104951) (cherry picked from commit 2cb445635e99d4401949cabebd373288cfdd0138) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.11] Improve test coverage for is_typeddict (GH-104884) (#104888)Miss Islington (bot)2023-05-241-3/+16
| | | | | | | In particular, it's important to test that is_typeddict(TypedDict) returns False. (cherry picked from commit 1497607a8e99f1103c40368dd5f9057f0146a520) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.11] typing: Add more tests for TypeVar (GH-104571) (#104577)Jelle Zijlstra2023-05-171-0/+27
| | | | | | | | During the PEP 695 implementation at one point I made TypeVar.__name__ return garbage, and all of test_typing passed. So I decided to add a few more tests. (cherry picked from commit 26931944dd8abd6554249239344fa62b789b9028) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* [3.11] gh-104036: Fix direct invocation of test_typing (GH-104037) (#104039)Miss Islington (bot)2023-05-011-1/+1
| | | | | | | | gh-104036: Fix direct invocation of test_typing (GH-104037) Previously, `python -m test test_typing` worked, but `python Lib/test/test_typing.py` did not. (cherry picked from commit 4181d078fc945313568eb39965cb9190881606b5) Co-authored-by: Kirill Podoprigora <80244920+Eclips4@users.noreply.github.com>
* [3.11] gh-103746: Test `types.UnionType` and `Literal` types together ↵Miss Islington (bot)2023-04-241-0/+5
| | | | | | | | (GH-103747) (#103772) gh-103746: Test `types.UnionType` and `Literal` types together (GH-103747) (cherry picked from commit 3d29edaf0a5f2e12e7f72552f602c761ddaf0d13) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] gh-103592: Add tests of `Literal` with `Enum` and `Union` of ↵Miss Islington (bot)2023-04-231-0/+45
| | | | | | | | `Literal`s (GH-103706) (#103720) gh-103592: Add tests of `Literal` with `Enum` and `Union` of `Literal`s (GH-103706) (cherry picked from commit 5041c2ba6e9c992d1c54834481c9be64581c0235) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-103395: Improve `typing._GenericAlias.__dir__` coverage (GH-103396)Miss Islington (bot)2023-04-101-2/+61
| | | | | (cherry picked from commit a28e2ce3fbcc852959324879e0bbf5ba8ecf0105) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-74690: Add more tests for runtime-checkable protocols (GH-103347)Miss Islington (bot)2023-04-071-2/+39
| | | | | (cherry picked from commit 800382a2b0980c21dfb2a8ac02aaf1e881f987b9) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* gh-103054: typing: Improve `Callable` type substitution tests (GH-103055)Miss Islington (bot)2023-03-291-0/+42
| | | | | | | (cherry picked from commit 60bdc16b459cf8f7b359c7f87d8ae6c5928147a4) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
* gh-88965: typing: fix type substitution of a list of types after initial ↵Miss Islington (bot)2023-03-231-0/+121
| | | | | | | | | | | | | | | | | | | | | | `ParamSpec` substitution (GH-102808) Previously, this used to fail: ```py from typing import * T = TypeVar("T") P = ParamSpec("P") class X(Generic[P]): f: Callable[P, int] Y = X[[int, T]] Z = Y[str] ``` (cherry picked from commit adb0621652f489033b9db8d3949564c9fe545c1d) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* [3.11] gh-102721: Improve coverage of ↵Nikita Sobolev2023-03-171-7/+32
| | | | | | | `_collections_abc._CallableGenericAlias` (GH-102788) This is a backport of https://github.com/python/cpython/pull/102722 without the `typing.py` changes. Automerge-Triggered-By: GH:AlexWaygood
* gh-102433: Add tests for how classes with properties interact with ↵Miss Islington (bot)2023-03-111-0/+88
| | | | | | | | `isinstance()` checks on `typing.runtime_checkable` protocols (GH-102449) (cherry picked from commit 5ffdaf748d98da6065158534720f1996a45a0072) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Carl Meyer <carl@oddbird.net>
* gh-102444: Fix minor bugs in `test_typing` highlighted by pyflakes (GH-102445)Miss Islington (bot)2023-03-051-19/+2
| | | | | (cherry picked from commit 96e10229292145012bc462a6ab3ce1626c8acf71) Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* Fix unused classes in a typing test (GH-102437)Miss Islington (bot)2023-03-051-2/+2
| | | | | | | As part of investigation issue https://github.com/python/cpython/issues/102433, I discovered what I believe to be an error where two classes `CI` and `DI` are not being used. The assertions beneath them act on `C` and `D`, duplicating existing assertions in this test. (cherry picked from commit 7894bbe94ba319eb650f383cb5196424c77b2cfd) Co-authored-by: JosephSBoyle <48555120+JosephSBoyle@users.noreply.github.com> Automerge-Triggered-By: GH:AlexWaygood
* gh-101562: typing: add tests for inheritance with NotRequired & Required in ↵Miss Islington (bot)2023-02-061-0/+33
| | | | | | | parent fields (GH-101563) (cherry picked from commit b96b344f251954bb64aeb13c3e0c460350565c2a) Co-authored-by: Eclips4 <80244920+Eclips4@users.noreply.github.com>
* gh-101015: Fix `typing.get_type_hints` with unpacked `*tuple` (PEP 646) ↵Miss Islington (bot)2023-01-231-0/+30
| | | | | | | (GH-101031) (cherry picked from commit 807d6b576fa37f3ab7eb951297cb365c0c198595) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-99344, gh-99379, gh-99382: Fix issues in substitution of ParamSpec and ↵Miss Islington (bot)2022-11-291-0/+81
| | | | | | | | | | | | | TypeVarTuple (GH-99412) * Fix substitution of TypeVarTuple and ParamSpec together in user generics. * Fix substitution of ParamSpec followed by TypeVarTuple in generic aliases. * Check the number of arguments in substitution in user generics containing a TypeVarTuple and one or more TypeVar. (cherry picked from commit 8f2fb7dfe72c882e97e524ef7ce40ceb663cc27e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* `test_typing`: use all pickle protocols (GH-99154)Miss Islington (bot)2022-11-061-1/+1
| | | | | (cherry picked from commit a0bc75e2fdd53680cb147881bcb3754bd56aa2fa) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-98852: Fix subscription of type aliases (GH-98920)Miss Islington (bot)2022-11-011-0/+28
| | | | | | | | Fix subscription of type aliases containing bare generic types or types like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int], where A is a generic type, and T is a type variable. (cherry picked from commit 0e15c31c7e9907fdbe38a3f419b669fed5bb3b33) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-98713: Use `@cpython_only` for a test that fails on PyPy (GH-98714)Miss Islington (bot)2022-10-261-1/+2
| | | | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> (cherry picked from commit 9495360c7256938a6185838561cf416599b7e94f) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] GH-87390: Add remaining tests for PEP 646 (GH-98267) (#98667)Jelle Zijlstra2022-10-261-190/+478
| | | | | | | Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>. Co-authored-by: Matthew Rahtz <matthew.rahtz@gmail.com> (cherry picked from commit cb95cc24efecf32ad035318867b065a2b042d25a)
* Use more precise exception types in `assertRaises` in typing tests (GH-98650)Miss Islington (bot)2022-10-251-3/+3
| | | | | (cherry picked from commit 45c89358b71e4638455e75ba6e60b42c511bbc2a) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* typing tests: `_overload_dummy` raises `NotImplementedError`, not ↵Miss Islington (bot)2022-10-201-1/+1
| | | | | | | `RuntimeError` (GH-98351) (cherry picked from commit 1ca6647f22794f0a0c982ecb03e764db76d51087) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] gh-95987: Fix `repr` of `Any` type subclasses (GH-96412) (#96451)Shantanu2022-10-051-0/+6
| | | | | (cherry picked from commit 4217393) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* [3.11] gh-96357: Improve `typing.get_overloads` coverage (GH-96358) (#96371)Miss Islington (bot)2022-09-291-0/+3
| | | | | | gh-96357: Improve `typing.get_overloads` coverage (GH-96358) (cherry picked from commit 675e3470ccf3804a36a9cd451b813e9bd655aeb3) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-96478: Fix new test when run in refleak mode (GH-96615)Miss Islington (bot)2022-09-271-12/+12
| | | | | | | ./python.exe -m test -R : test.test_typing would fail, apparently because the dictionary used in the @patch decorator was modified. (cherry picked from commit f0d9136c69b4ed32bfb3096f926da098623a7072) Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-96478: Test `@overload` on C functions (GH-96479)Miss Islington (bot)2022-09-211-0/+14
| | | | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> (cherry picked from commit f177f6f29b069f522a0b3ba44eaae19852b6d2b0) Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-96385: Correctly raise error on `[*T, *V]` substitution (GH-96386) (#96407)Miss Islington (bot)2022-08-301-0/+3
| | | | | | | (cherry picked from commit 75177358a62afeabd1d3aa0e9f395c2b9d4495ca) Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* gh-94607: Fix subclassing generics (GH-94610)Miss Islington (bot)2022-07-091-0/+29
| | | | | | Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com> (cherry picked from commit 6442a9dd212fa18343db21849cf05c0181662c1f) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* gh-94245: Test pickling and copying of typing.Tuple[()] (GH-94259)Miss Islington (bot)2022-06-251-2/+4
| | | | | (cherry picked from commit 75cb3abc3bf10c7be3b374bfb4c060c36d251411) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] gh-91162: Support splitting of unpacked arbitrary-length tuple over ↵Miss Islington (bot)2022-06-141-7/+10
| | | | | | | | | | | | TypeVar and TypeVarTuple parameters (alt) (GH-93412) (GH-93746) For example: A[T, *Ts][*tuple[int, ...]] -> A[int, *tuple[int, ...]] A[*Ts, T][*tuple[int, ...]] -> A[*tuple[int, ...], int] (cherry picked from commit 3473817106c23eca7341c931453da0341c367e1d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-93345: Fix a crash in substitution of nested TypeVar after TypeVarTuple ↵Miss Islington (bot)2022-06-011-1/+7
| | | | | | | | (GH-93346) For example: tuple[*Ts, list[T]][int, str, bool] (cherry picked from commit f545fc955aeb701ae4e73b07ff2283f823d857b8) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* [3.11] gh-91162: Fix substitution of unpacked tuples in generic aliases ↵Miss Islington (bot)2022-06-011-106/+47
| | | | | | | | | | | | | (GH-92335) (#92484) * gh-91162: Fix substitution of unpacked tuples in generic aliases (GH-92335) (cherry picked from commit 9d25db9db1617f012d7dba118b5b8f2b9e25e116) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> * Regenerate ABI file Co-authored-by: Serhiy Storchaka <storchaka@gmail.com> Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* gh-92261: Disallow iteration of Union (and other special forms) (GH-92262) ↵Miss Islington (bot)2022-05-101-0/+31
| | | | | | | | (GH-92582) (cherry picked from commit 4739997e141c4c84bd2241d4d887c3c658d92700) Co-authored-by: Matthew Rahtz <matthew.rahtz@gmail.com>
* gh-92107: Add tests that subscription works on arbitrary named tuple types ↵Serhiy Storchaka2022-05-041-0/+14
| | | | (GH-92304)
* bpo-44863: Allow generic typing.TypedDict (#27663)Samodya Abey2022-05-031-0/+136
| | | | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* gh-91621: Fix typing.get_type_hints for collections.abc.Callable (#91656)Shantanu2022-05-021-0/+11
| | | | | | This mirrors logic in typing.get_args. The trickiness comes from how we flatten args in collections.abc.Callable, see https://bugs.python.org/issue42195
* bpo-43923: Add support for generic typing.NamedTuple (#92027)Serhiy Storchaka2022-05-021-0/+39
|
* gh-92106: Add test that subscription works on arbitrary TypedDicts (#92176)Serhiy Storchaka2022-05-021-0/+13
|
* bpo-43224: Implement substitution of unpacked TypeVarTuple in C (GH-31828)Serhiy Storchaka2022-04-301-24/+39
| | | | Co-authored-by: Matthew Rahtz <mrahtz@gmail.com>
* gh-92064: Fix global variable name collision in test_typing (#92067)Dennis Sweeney2022-04-301-13/+13
| | | Fixes #92064