summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44524: Fix cryptic TypeError message when trying to subclass special ↵Miss Islington (bot)2021-08-281-0/+16
| | | | | | | | forms in `typing` (GH-27710) This was a Python 3.9 regression. (cherry picked from commit a3a4d20d6798aa2975428d51f3a4f890248810cb) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44524: Don't modify MRO when inheriting from typing.Annotated (GH-27841)Miss Islington (bot)2021-08-251-0/+5
| | | | | (cherry picked from commit 23384a1749359f0ae7aaae052073d44b59e715a1) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-44524: Do not set _name of _SpecialForm without need (GH-27861) (GH-27871)Miss Islington (bot)2021-08-211-1/+0
| | | | | | | | | Because setting non-empty _name affects behavior of other code. In most cases __name__ can be derived from __origin__.__name__. (cherry picked from commit 4ceec495598e78f0776dd46d511dcc612a434dc3) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44524: Fix an issue wherein `_GenericAlias._name` was not properly set ↵Miss Islington (bot)2021-08-061-54/+173
| | | | | | | | | for specialforms (GH-27614) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 8bdf12e99a3dc7ada5f85bba79c2a9eb9931f5b0) Co-authored-by: Bas van Beek <43369155+BvB93@users.noreply.github.com>
* bpo-44801: Check arguments in substitution of ParamSpec in Callable (GH-27585)Miss Islington (bot)2021-08-041-3/+42
| | | | | (cherry picked from commit 3875a6954741065b136650db67ac533bc70a3eac) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44806: Fix __init__ in subclasses of protocols (GH-27545)Miss Islington (bot)2021-08-021-0/+36
| | | | | | | Non-protocol subclasses of protocol ignore now the __init__ method inherited from protocol base classes. (cherry picked from commit 043cd60abed09edddc7185bcf7d039771acc734d) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44793: Fix checking the number of arguments when subscribe a generic ↵Miss Islington (bot)2021-08-021-2/+4
| | | | | | | | | | | type with ParamSpec parameter. (GH-27515) For example Callable[P, T][[int], str, float] will now raise an error. Use also term "arguments" instead of "parameters" in error message for too few/many arguments. (cherry picked from commit f92b9133ef67e77605cbd315b6b6c81036ce110e) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44794: Merge tests for typing.Callable and collection.abc.Callable ↵Miss Islington (bot)2021-07-311-25/+140
| | | | | | | (GH-27507) (cherry picked from commit be4cb9089aaf58d5f90da5f9fa66dc3c6763b5a2) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44761: Change default value of NewType __module__ attr (GH-27406) (GH-27477)Miss Islington (bot)2021-07-301-0/+6
| | | | | (cherry picked from commit 7b975f81e4dba70a42c6279539a7fcfe4211b4c0) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44662: Add ability to annotate types.Union (GH-27214) (GH-27461)Miss Islington (bot)2021-07-301-0/+10
| | | | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 8182c8329c709f42218a8a17d81639ece5b7b627) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44732: Rename types.Union to types.UnionType (GH-27342)Miss Islington (bot)2021-07-261-1/+1
| | | | | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com> (cherry picked from commit 2b8ad9e6c5f0a66e9ca2d15f85336d8a3eefefb0) Co-authored-by: Hasan <hasan.aleeyev@gmail.com>
* bpo-44353: Improve tests covering typing.NewType pickling (GH-27302) (GH-27328)Miss Islington (bot)2021-07-241-8/+9
| | | | | (cherry picked from commit a22b05da87bdfb081d6aaecfce136ae8dbb8680c) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* [3.10] bpo-44353: Expand NewType tests for complex __qualname__ (GH-27311) ↵Łukasz Langa2021-07-241-14/+42
| | | | | | | | (GH-27326) Make NewType pickleable by name. (cherry picked from commit e89ef0ad2a299770a88ece8f7a316f7d3eb65c9f) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
* bpo-44353: Add test to cover __or__ of two NewType (GH-27259) (#27261)Miss Islington (bot)2021-07-201-4/+7
| | | | | (cherry picked from commit 4868b94c6089d457673b1ba5b5b64c2f38c435af) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44353: Refactor typing.NewType into callable class (GH-27250) (#27258)Miss Islington (bot)2021-07-201-0/+20
| | | | | (cherry picked from commit 965dd76e9060e27e2253ba8c8d21a142b178720d) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44524: Add missed __name__ and __qualname__ to typing module objects ↵Miss Islington (bot)2021-07-191-0/+61
| | | | | | | | (GH-27237) (#27246) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit bce1418541a64a793960182772f985f64afbfa1a) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-44490: Improve typing module compatibility with types.Union (GH-27048) ↵Ken Jin2021-07-191-1/+21
| | | | | | | (#27222) (cherry picked from commit bf89ff96e6ba21bb52b8597b5e51e8ffc57e6589) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-41249: Fix postponed annotations for TypedDict (GH-27017) (#27204)Miss Islington (bot)2021-07-171-0/+10
| | | | | | | | | | This fixes TypedDict to work with get_type_hints and postponed evaluation of annotations across modules. This is done by adding the module name to ForwardRef at the time the object is created and using that to resolve the globals during the evaluation. Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> (cherry picked from commit 889036f7ef7290ef15b6c3373023f6a35387af0c) Co-authored-by: Germán Méndez Bravo <german.mb@gmail.com>
* [3.10] bpo-44468: Never skip base classes in `typing.get_type_hints()`, even ↵Miss Islington (bot)2021-06-261-7/+18
| | | | | | | | | | with invalid `.__module__`. (GH-26862) (GH-26920) (cherry picked from commit 7569c0fe91dfcf562dee8c29798ecda74d738aa8) Co-authored-by: will-ca <willchencontact@gmail.com> Automerge-Triggered-By: GH:gvanrossum
* bpo-44098: Drop ParamSpec from most ``__parameters__`` in typing generics ↵Miss Islington (bot)2021-05-131-0/+25
| | | | | | | | | | | (GH-26013) (#26091) Added two new attributes to ``_GenericAlias``: * ``_typevar_types``, a single type or tuple of types indicating what types are treated as a ``TypeVar``. Used for ``isinstance`` checks. * ``_paramspec_tvars ``, a boolean flag which guards special behavior for dealing with ``ParamSpec``. Setting it to ``True`` means this class deals with ``ParamSpec``. Automerge-Triggered-By: GH:gvanrossum (cherry picked from commit b2f3f8e3d81b0bb0ba18f563d82c28ba133c0790)
* bpo-38908: Fix issue when non runtime_protocol failed to raise TypeError ↵Miss Islington (bot)2021-05-121-0/+8
| | | | | | | (GH-26067) (cherry picked from commit c40486a32d7e37b01ead94e701d69847f5b60e30) Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
* bpo-43766: Implement PEP 647 (User-Defined Type Guards) in typing.py (#25282)Ken Jin2021-04-271-0/+40
|
* bpo-42904: Change search order of typing.get_type_hints eval (#25632)Ken Jin2021-04-261-2/+2
| | | While surprising (searching globals before locals in one specific case), this is needed for backwards compatibility.
* bpo-38605: Revert making 'from __future__ import annotations' the default ↵Pablo Galindo2021-04-211-11/+11
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo41515: Fix assert in test which throws SyntaxWarning. (#25379)Karthikeyan Singaravelan2021-04-131-1/+1
|
* bpo-41515: Fix KeyError raised in get_type_hints (GH-25352)Karthikeyan Singaravelan2021-04-121-0/+6
| | | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: efahl <36704995+efahl@users.noreply.github.com>
* bpo-42904: Fix get_type_hints for class local namespaces (GH-24201)Ken Jin2021-04-121-1/+8
|
* bpo-43772: Fix TypeVar.__ror__ (GH-25339)Jelle Zijlstra2021-04-111-0/+10
|
* bpo-43783: Add ParamSpecArgs/Kwargs (GH-25298)Jelle Zijlstra2021-04-111-4/+12
|
* bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin (GH-23942)Ken Jin2020-12-291-0/+6
|
* bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963)Ken Jin2020-12-281-0/+5
| | | PR 1/2. Needs backport to 3.9.
* bpo-41559: Implement PEP 612 - Add ParamSpec and Concatenate to typing (#23702)kj2020-12-241-14/+106
|
* bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and ↵kj2020-12-131-20/+6
| | | | typing (GH-23060)
* bpo-42059: Fix required/optional keys for TypedDict(..., total=False) (GH-22736)Alex Grönholm2020-12-101-0/+4
|
* bpo-42345: Fix hash implementation of typing.Literal (GH-23383)Yurii Karabas2020-11-191-0/+5
| | | | | | | Fix hash implementation of `typing.Literal`. Update docs regarding `typing.Litaral` caching. Base implementation was done in PR #23294.
* bpo-42345: Fix three issues with typing.Literal parameters (GH-23294)Yurii Karabas2020-11-171-0/+25
| | | | | | | Literal equality no longer depends on the order of arguments. Fix issue related to `typing.Literal` caching by adding `typed` parameter to `typing._tp_cache` function. Add deduplication of `typing.Literal` arguments.
* bpo-42233: Correctly repr GenericAlias when used with typing module (GH-23081)kj2020-11-011-0/+7
| | | | | | | | | | | | | | | Noticed by @serhiy-storchaka in the bpo. `typing`'s types were not showing the parameterized generic. Eg. previously: ```python >>> typing.Union[dict[str, float], list[int]] 'typing.Union[dict, list]' ``` Now: ```python >>> typing.Union[dict[str, float], list[int]] 'typing.Union[dict[str, float], list[int]]' ``` Automerge-Triggered-By: GH:gvanrossum
* bpo-41923: PEP 613: Add TypeAlias to typing module (#22532)Mikhail Golubev2020-10-071-0/+40
| | | | | This special marker annotation is intended to help in distinguishing proper PEP 484-compliant type aliases from regular top-level variable assignments.
* bpo-38605: Make 'from __future__ import annotations' the default (GH-20434)Batuhan Taskaya2020-10-061-12/+12
| | | | | The hard part was making all the tests pass; there are some subtle issues here, because apparently the future import wasn't tested very thoroughly in previous Python versions. For example, `inspect.signature()` returned type objects normally (except for forward references), but strings with the future import. We changed it to try and return type objects by calling `typing.get_type_hints()`, but fall back on returning strings if that function fails (which it may do if there are future references in the annotations that require passing in a specific namespace to resolve).
* bpo-41792: Add is_typeddict function to typing.py (GH-22254)Patrick Reader2020-09-161-0/+7
| | | | | Closes issue41792. Also closes https://github.com/python/typing/issues/751.
* bpo-41428: Implementation for PEP 604 (GH-21515)Maggie Moss2020-09-091-6/+0
| | | | | See https://www.python.org/dev/peps/pep-0604/ for more information. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* bpo-41521: Replace whitelist/blacklist with allowlist/denylist (GH-21823)Victor Stinner2020-08-111-1/+1
| | | Rename 5 test method names in test_codecs and test_typing.
* bpo-41341: Recursive evaluation of ForwardRef in get_type_hints (#21553)wyfo2020-07-221-0/+6
| | | | | | The issue raised by recursive evaluation is infinite recursion with recursive types. In that case, only the first recursive ForwardRef is evaluated.
* bpo-39168: Remove the __new__ method of typing.Generic (GH-21327)Zackery Spytz2020-07-051-2/+0
| | | Automerge-Triggered-By: @gvanrossum
* bpo-40397: Fix subscription of nested generic alias without parameters. ↵Serhiy Storchaka2020-05-101-1/+12
| | | | (GH-20021)
* bpo-40389: Improve repr of typing.Optional (#19714)Vlad Serebrennikov2020-04-301-1/+1
|
* bpo-40443: Remove unused imports in tests (GH-19805)Victor Stinner2020-04-291-1/+1
|
* bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)Serhiy Storchaka2020-04-271-2/+7
|
* bpo-40396: Support GenericAlias in the typing functions. (GH-19718)Serhiy Storchaka2020-04-261-1/+41
|
* bpo-39942:Fix failure in `TypeVar` when missing `__name__` (GH-19616)HongWeipeng2020-04-201-0/+7
| | | https://bugs.python.org/issue39942