Jelle Zijlstra
83c8df29dd
[3.11] GH-87390: Add remaining tests for PEP 646 (GH-98267) ( #98667 )
...
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>.
Co-authored-by: Matthew Rahtz <matthew.rahtz@gmail.com>
(cherry picked from commit cb95cc24ef
)
2022-10-25 18:46:57 -07:00
Miss Islington (bot)
abc1a8c61c
Use more precise exception types in `assertRaises` in typing tests (GH-98650)
...
(cherry picked from commit 45c89358b7
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-25 07:19:37 -07:00
Miss Islington (bot)
5f5fa4ca4b
typing tests: `_overload_dummy` raises `NotImplementedError`, not `RuntimeError` (GH-98351)
...
(cherry picked from commit 1ca6647f22
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-19 18:23:40 -07:00
Shantanu
c9eacc8d02
[3.11] gh-95987: Fix `repr` of `Any` type subclasses (GH-96412) ( #96451 )
...
(cherry picked from commit 4217393
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-10-05 15:02:06 -07:00
Miss Islington (bot)
f418842a5c
[3.11] gh-96357: Improve `typing.get_overloads` coverage (GH-96358) ( #96371 )
...
gh-96357: Improve `typing.get_overloads` coverage (GH-96358)
(cherry picked from commit 675e3470cc
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-28 18:06:21 -07:00
Miss Islington (bot)
f391b3c6ab
gh-96478: Fix new test when run in refleak mode (GH-96615)
...
./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 f0d9136c69
)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-09-27 07:50:36 -07:00
Miss Islington (bot)
2a5e333736
gh-96478: Test `@overload` on C functions (GH-96479)
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
(cherry picked from commit f177f6f29b
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-09-20 18:36:23 -07:00
Miss Islington (bot)
16d8948c31
gh-96385: Correctly raise error on `[*T, *V]` substitution (GH-96386) ( #96407 )
...
(cherry picked from commit 75177358a6
)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
2022-08-30 11:58:54 +01:00
Miss Islington (bot)
b4e232c4b5
gh-94607: Fix subclassing generics (GH-94610)
...
Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com>
(cherry picked from commit 6442a9dd21
)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2022-07-08 22:20:43 -07:00
Miss Islington (bot)
125146771c
gh-94245: Test pickling and copying of typing.Tuple[()] (GH-94259)
...
(cherry picked from commit 75cb3abc3b
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-06-25 09:10:08 -07:00
Miss Islington (bot)
8dc5df4e21
[3.11] gh-91162: Support splitting of unpacked arbitrary-length tuple over 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 3473817106
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-06-14 21:15:56 +03:00
Miss Islington (bot)
3265ff9ccc
gh-93345: Fix a crash in substitution of nested TypeVar after TypeVarTuple (GH-93346)
...
For example: tuple[*Ts, list[T]][int, str, bool]
(cherry picked from commit f545fc955a
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-05-31 23:43:38 -07:00
Miss Islington (bot)
00f8fe9564
[3.11] gh-91162: Fix substitution of unpacked tuples in generic aliases (GH-92335) ( #92484 )
...
* gh-91162: Fix substitution of unpacked tuples in generic aliases (GH-92335)
(cherry picked from commit 9d25db9db1
)
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>
2022-06-01 03:13:27 +01:00
Miss Islington (bot)
7540a432ce
gh-92261: Disallow iteration of Union (and other special forms) (GH-92262) (GH-92582)
...
(cherry picked from commit 4739997e14
)
Co-authored-by: Matthew Rahtz <matthew.rahtz@gmail.com>
2022-05-10 08:39:31 +03:00
Serhiy Storchaka
9d20e1af40
gh-92107: Add tests that subscription works on arbitrary named tuple types (GH-92304)
2022-05-04 17:06:50 +03:00
Samodya Abey
f6f36cc269
bpo-44863: Allow generic typing.TypedDict ( #27663 )
...
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>
2022-05-03 07:21:42 -06:00
Shantanu
ebb8b512e9
gh-91621: Fix typing.get_type_hints for collections.abc.Callable ( #91656 )
...
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
2022-05-02 17:08:28 -06:00
Serhiy Storchaka
b04e02c57f
bpo-43923: Add support for generic typing.NamedTuple ( #92027 )
2022-05-02 16:41:23 -06:00
Serhiy Storchaka
81fb3548be
gh-92106: Add test that subscription works on arbitrary TypedDicts ( #92176 )
2022-05-02 16:38:39 -06:00
Serhiy Storchaka
e8c2f72b94
bpo-43224: Implement substitution of unpacked TypeVarTuple in C (GH-31828)
...
Co-authored-by: Matthew Rahtz <mrahtz@gmail.com>
2022-04-30 08:22:46 +03:00
Dennis Sweeney
a29aa76a3f
gh-92064: Fix global variable name collision in test_typing ( #92067 )
...
Fixes #92064
2022-04-29 21:18:38 -06:00
Serhiy Storchaka
81120b6754
bpo-44791: Accept ellipsis as the last argument of typing.Concatenate ( #30969 )
2022-04-29 15:01:40 -06:00
Matthew Rahtz
f6656163de
gh-87390: Add tests demonstrating current type variable substitution behaviour ( #32341 )
2022-04-29 14:03:21 -06:00
Jelle Zijlstra
5397b5afc1
gh-91860: Add typing.dataclass_transform (PEP 681) ( #91861 )
...
Copied from typing-extensions (python/typing#1054 , python/typing#1120 ).
Documentation is intentionally omitted, so we can focus on getting the
runtime part in before the feature freeze.
2022-04-25 20:30:25 -07:00
Jelle Zijlstra
93d280141c
gh-90633: Improve error and docs for typing.assert_never ( #91720 )
...
Closes #90633
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-04-25 06:40:18 -07:00
Matthew Rahtz
5e130a8da4
bpo-43224: Implement pickling of TypeVarTuples ( #32119 )
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-21 21:22:53 -07:00
Jelle Zijlstra
055760ed9e
gh-89263: Add typing.get_overloads (GH-31716)
...
Based on suggestions by Guido van Rossum, Spencer Brown, and Alex Waygood.
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
2022-04-16 09:01:43 -07:00
Matthew Rahtz
f2bc12f0d5
bpo-43224: Add tests for TypeVarTuple substitution in Annotated (GH-31846)
2022-04-15 21:24:28 -07:00
Serhiy Storchaka
15537c51c1
bpo-43224: Forbid TypeVar substitution with Unpack (GH-32031)
2022-04-12 20:08:49 -07:00
Jelle Zijlstra
ac6c3de03c
gh-91243: Add typing.Required and NotRequired (PEP 655) (GH-32419)
...
I talked to @davidfstr and I offered to implement the runtime part of PEP 655
to make sure we can get it in before the feature freeze. We're going to defer
the documentation to a separate PR, because it can wait until after the feature
freeze.
The runtime implementation conveniently already exists in typing-extensions,
so I largely copied that.
Co-authored-by: David Foster <david@dafoster.net>
2022-04-12 12:31:02 -07:00
Adrian Garcia Badaracco
5f2abae61e
bpo-44807: Allow Protocol classes to define __init__ (GH-31628)
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-11 07:51:25 -07:00
Jelle Zijlstra
cfb849a326
bpo-47088: Add typing.LiteralString (PEP 675) (GH-32064)
...
Co-authored-by: Nick Pope <nick@nickpope.me.uk>
2022-04-05 07:21:03 -07:00
Shantanu
5a4973e29f
bpo-46998: Allow subclassing Any at runtime (GH-31841)
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-04-04 19:35:29 -07:00
Jelle Zijlstra
3a2b89580d
bpo-43224: Add TypeVarTuple.__name__ (GH-31954)
...
I noticed that TypeVar and ParamSpec put their name in a __name__
attribute, but TypeVarTuple doesn't. Let's be consistent.
2022-03-18 10:56:36 -07:00
Serhiy Storchaka
15df8f8d89
bpo-46981: Remove typing._TypingEmpty (GH-31836)
...
* get_args(Tuple[()]) now returns () instead of ((),).
* Tuple[Unpack[Ts]][()] now returns the result equal to Tuple[()].
2022-03-17 09:52:24 +02:00
Jelle Zijlstra
96568e995d
bpo-46480: add typing.assert_type (GH-30843)
...
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: David Foster <david@dafoster.net>
2022-03-16 20:02:26 -07:00
Jelle Zijlstra
75174371e6
bpo-46644: Fix test_typing test broken by GH-31151 due to a merge race (GH-31833)
2022-03-11 18:17:45 -08:00
Gregory Beauregard
870b22b9c4
bpo-46644: Remove callable() requirement from typing._type_check (GH-31151)
...
We also remove all the tests that check for integer literals.
2022-03-11 17:12:17 -08:00
Serhiy Storchaka
5b1b9eacb9
bpo-43224: Implement substitution of unpacked TypeVarTuple (GH-31800)
2022-03-11 21:43:58 +02:00
Serhiy Storchaka
b6a5d8590c
bpo-44796: Unify TypeVar and ParamSpec substitution (GH-31143)
...
Add methods __typing_subst__() in TypeVar and ParamSpec.
Simplify code by using more object-oriented approach, especially
the C code for types.GenericAlias and the Python code for
collections.abc.Callable.
2022-03-11 10:47:26 +02:00
Matt Bogosian
32bf359792
bpo-46581: Propagate private vars via _GenericAlias.copy_with (GH-31061)
...
GH-26091 added the _typevar_types and _paramspec_tvars instance
variables to _GenericAlias. However, they were not propagated
consistently. This commit addresses the most prominent deficiency
identified in bpo-46581 (namely their absence from
_GenericAlias.copy_with), but there could be others.
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
2022-03-10 16:42:15 +02:00
Matthew Rahtz
7a793a388b
bpo-43224: Implement PEP 646 changes to typing.py (GH-31021)
...
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-07 20:02:55 -08:00
James Hilton-Balfe
f391f9bf28
bpo-46170: Improve the error message when subclassing NewType (GH-30268)
...
Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
2022-03-07 19:50:46 -08:00
Niklas Rosenstein
b465b60604
bpo-41370: Evaluate strings as forward refs in PEP 585 generics (GH-30900)
...
This removes discrepancy between list["int"] and List["int"].
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
2022-03-07 10:02:59 -08:00
Serhiy Storchaka
6927632492
Remove trailing spaces (GH-31695)
2022-03-05 17:47:00 +02:00
Gregory Beauregard
75d2d945b4
bpo-46643: Fix stringized P.args/P.kwargs with get_type_hints (GH-31238)
2022-03-02 17:14:52 -08:00
Nikita Sobolev
20a1c8ee4b
bpo-46195: Do not add `Optional` in `get_type_hints` (GH-30304)
...
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2022-03-01 21:29:46 -08:00
Jelle Zijlstra
0a8a8e7454
bpo-46066: Check DeprecationWarning in test_typing (GH-31428)
2022-02-19 17:44:51 -08:00
Nikita Sobolev
32e3e0bea6
bpo-46685: improve test coverage of `Self` and `Never` in `typing` (GH-31222)
2022-02-18 17:56:30 -08:00
Nikita Sobolev
25c0b9d243
bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063)
2022-02-18 17:54:01 -08:00