summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
* bpo-44791: Accept ellipsis as the last argument of typing.Concatenate (#30969)Serhiy Storchaka2022-04-291-8/+4
|
* gh-87390: Add tests demonstrating current type variable substitution ↵Matthew Rahtz2022-04-291-0/+387
| | | | behaviour (#32341)
* gh-91860: Add typing.dataclass_transform (PEP 681) (#91861)Jelle Zijlstra2022-04-261-0/+86
| | | | | | | 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.
* gh-90633: Improve error and docs for typing.assert_never (#91720)Jelle Zijlstra2022-04-251-0/+13
| | | | | Closes #90633 Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
* bpo-43224: Implement pickling of TypeVarTuples (#32119)Matthew Rahtz2022-04-221-1/+55
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-89263: Add typing.get_overloads (GH-31716)Jelle Zijlstra2022-04-161-4/+68
| | | | | | | 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>
* bpo-43224: Add tests for TypeVarTuple substitution in Annotated (GH-31846)Matthew Rahtz2022-04-161-0/+71
|
* bpo-43224: Forbid TypeVar substitution with Unpack (GH-32031)Serhiy Storchaka2022-04-131-0/+14
|
* gh-91243: Add typing.Required and NotRequired (PEP 655) (GH-32419)Jelle Zijlstra2022-04-121-1/+173
| | | | | | | | | | | 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>
* bpo-44807: Allow Protocol classes to define __init__ (GH-31628)Adrian Garcia Badaracco2022-04-111-0/+26
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-47088: Add typing.LiteralString (PEP 675) (GH-32064)Jelle Zijlstra2022-04-051-1/+55
| | | Co-authored-by: Nick Pope <nick@nickpope.me.uk>
* bpo-46998: Allow subclassing Any at runtime (GH-31841)Shantanu2022-04-051-13/+15
| | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-43224: Add TypeVarTuple.__name__ (GH-31954)Jelle Zijlstra2022-03-181-9/+6
| | | | I noticed that TypeVar and ParamSpec put their name in a __name__ attribute, but TypeVarTuple doesn't. Let's be consistent.
* bpo-46981: Remove typing._TypingEmpty (GH-31836)Serhiy Storchaka2022-03-171-5/+3
| | | | | * get_args(Tuple[()]) now returns () instead of ((),). * Tuple[Unpack[Ts]][()] now returns the result equal to Tuple[()].
* bpo-46480: add typing.assert_type (GH-30843)Jelle Zijlstra2022-03-171-1/+17
| | | | Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: David Foster <david@dafoster.net>
* bpo-46644: Fix test_typing test broken by GH-31151 due to a merge race ↵Jelle Zijlstra2022-03-121-1/+1
| | | | (GH-31833)
* bpo-46644: Remove callable() requirement from typing._type_check (GH-31151)Gregory Beauregard2022-03-121-28/+4
| | | We also remove all the tests that check for integer literals.
* bpo-43224: Implement substitution of unpacked TypeVarTuple (GH-31800)Serhiy Storchaka2022-03-111-58/+85
|
* bpo-44796: Unify TypeVar and ParamSpec substitution (GH-31143)Serhiy Storchaka2022-03-111-20/+40
| | | | | | 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.
* bpo-46581: Propagate private vars via _GenericAlias.copy_with (GH-31061)Matt Bogosian2022-03-101-0/+21
| | | | | | | | | | 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>
* bpo-43224: Implement PEP 646 changes to typing.py (GH-31021)Matthew Rahtz2022-03-081-1/+431
| | | | Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-46170: Improve the error message when subclassing NewType (GH-30268)James Hilton-Balfe2022-03-081-0/+11
| | | | | 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>
* bpo-41370: Evaluate strings as forward refs in PEP 585 generics (GH-30900)Niklas Rosenstein2022-03-071-2/+42
| | | | | | 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>
* Remove trailing spaces (GH-31695)Serhiy Storchaka2022-03-051-2/+2
|
* bpo-46643: Fix stringized P.args/P.kwargs with get_type_hints (GH-31238)Gregory Beauregard2022-03-031-0/+12
|
* bpo-46195: Do not add `Optional` in `get_type_hints` (GH-30304)Nikita Sobolev2022-03-021-4/+15
| | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-46066: Check DeprecationWarning in test_typing (GH-31428)Jelle Zijlstra2022-02-201-4/+5
|
* bpo-46685: improve test coverage of `Self` and `Never` in `typing` (GH-31222)Nikita Sobolev2022-02-191-1/+48
|
* bpo-46603: improve coverage of `typing._strip_annotations` (GH-31063)Nikita Sobolev2022-02-191-0/+9
|
* bpo-46571: improve `typing.no_type_check` to skip foreign objects (GH-31042)Nikita Sobolev2022-02-191-0/+101
| | | | | | | | | | | | There are several changes: 1. We now don't explicitly check for any base / sub types, because new name check covers it 2. I've also checked that `no_type_check` do not modify foreign functions. It was the same as with `type`s 3. I've also covered `except TypeError` in `no_type_check` with a simple test case, it was not covered at all 4. I also felt like adding `lambda` test is a good idea: because `lambda` is a bit of both in class bodies: a function and an assignment <!-- issue-number: [bpo-46571](https://bugs.python.org/issue46571) --> https://bugs.python.org/issue46571 <!-- /issue-number -->
* bpo-46333: Honor `module` parameter in ForwardRef (GH-30536)aha792022-02-171-0/+12
| | | | | | | | | The `module` parameter carries semantic information about the forward ref. Forward refs are different if they refer to different module even if they have the same name. This affects the `__eq__`, `__repr__` and `__hash__` methods. Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com> Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-46066: Deprecate kwargs syntax for TypedDict definitions (GH-31126)97littleleaf112022-02-171-4/+6
| | | | | | Closes python/typing#981 https://bugs.python.org/issue46066
* bpo-46333: include `module` in `ForwardRef.__repr__` (#31283)aha792022-02-121-0/+2
| | | | | | | | The module parameter carries semantic information about the forward ref. Show to the user that forward refs with same argument but different module are different. Co-authored-by: Andreas Hangauer <andreas.hangauer@siemens.com> Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
* bpo-46685: cover `TypeError` of `ForwardRef(1)` in `test_typing` (GH-31223)Nikita Sobolev2022-02-091-0/+4
|
* bpo-46475: Add typing.Never and typing.assert_never (GH-30842)Jelle Zijlstra2022-02-081-15/+33
|
* bpo-46676: Make ParamSpec args and kwargs equal to themselves (GH-31203)Gregory Beauregard2022-02-081-0/+8
|