summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
Commit message (Collapse)AuthorAgeFilesLines
...
* bpo-44731: Simplify the union type implementation (GH-27318)Serhiy Storchaka2021-07-241-0/+6
| | | Remove direct support of typing types in the C code because they are already supported by defining methods __or__ and __ror__ in the Python code.
* bpo-44353: Expand NewType tests for complex __qualname__. (#27311)Serhiy Storchaka2021-07-241-1/+6
| | | Make NewType pickleable by name.
* bpo-44676: Add ability to serialize types.Union (GH-27244)Yurii Karabas2021-07-231-2/+2
|
* bpo-44353: Implement typing.NewType __call__ method in C (#27262)Yurii Karabas2021-07-221-3/+9
| | | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Denis Laxalde <denis@laxalde.org>
* bpo-44353: Refactor typing.NewType into callable class (GH-27250)Yurii Karabas2021-07-201-5/+22
|
* bpo-44524: Add missed __name__ and __qualname__ to typing module objects ↵Yurii Karabas2021-07-191-0/+9
| | | | | (#27237) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-44654: Refactor and clean up the union type implementation (GH-27196)Serhiy Storchaka2021-07-171-1/+1
|
* bpo-41249: Fix postponed annotations for TypedDict (GH-27017)Germán Méndez Bravo2021-07-171-7/+13
| | | | | | | | 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>
* bpo-44490: Improve typing module compatibility with types.Union (GH-27048)Yurii Karabas2021-07-171-5/+13
|
* bpo-44652: Preserve natural order of args in the union type. (GH-27185)Serhiy Storchaka2021-07-161-4/+4
|
* bpo-38291: Fix a spurious warning when using help(object) (#27039)Sebastian Rittau2021-07-061-1/+1
| | | | | | | help(object) via pydoc.TextDoc.docclass(object) iterates over the subclasses of object, which includes typing.io and typing.re if typing is imported. It tries to access cls.__module__ for each of those sub-classes. This change suppresses warnings when accessing cls.__module__.
* bpo-44468: Never skip base classes in `typing.get_type_hints()`, even with ↵will-ca2021-06-261-4/+1
| | | | invalid `.__module__`. (GH-26862)
* bpo-38291: DeprecationWarning when importing typing.{io,re} (#26719)Sebastian Rittau2021-06-191-2/+16
|
* bpo-44098: Drop ParamSpec from most ``__parameters__`` in typing generics ↵Ken Jin2021-05-131-14/+29
| | | | | | | | | (GH-26013) 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
* bpo-38908: Fix issue when non runtime_protocol failed to raise TypeError ↵Yurii Karabas2021-05-121-2/+10
| | | | (#26067)
* typing: format patch with make patchcheck (GH-25919)Dong-hee Na2021-05-051-1/+1
|
* bpo-38352: Add to typing.__all__ (#25821)Jelle Zijlstra2021-05-041-0/+7
| | | | | | This adds IO, TextIO, BinaryIO, Match, and Pattern. Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-43901: Lazy-create an empty annotations dict in all unannotated user ↵larryhastings2021-04-301-0/+2
| | | | | classes and modules (#25623) Change class and module objects to lazy-create empty annotations dicts on demand. The annotations dicts are stored in the object's `__dict__` for backwards compatibility.
* bpo-43766: Implement PEP 647 (User-Defined Type Guards) in typing.py (#25282)Ken Jin2021-04-271-0/+49
|
* bpo-42904: Change search order of typing.get_type_hints eval (#25632)Ken Jin2021-04-261-1/+10
| | | 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-7/+0
| | | | | | (GH-25490) This reverts commits 044a1048ca93d466965afc027b91a5a9eb9ce23c and 1be456ae9d53bb1cba2b24fc86175c282d1c2169, adapting the code to changes that happened after it.
* bpo-40443: Remove unused imports (GH-25429)Victor Stinner2021-04-161-1/+0
| | | | | | * pyclbr no longer uses copy * typing no longer uses ast Issue discovered by pyflakes.
* bpo-41515: Fix KeyError raised in get_type_hints (GH-25352)Karthikeyan Singaravelan2021-04-121-1/+4
| | | | | 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/+2
|
* bpo-43772: Fix TypeVar.__ror__ (GH-25339)Jelle Zijlstra2021-04-111-2/+2
|
* bpo-43783: Add ParamSpecArgs/Kwargs (GH-25298)Jelle Zijlstra2021-04-111-3/+50
|
* Fix various ParamSpec errors in typing (GH-24176)Ken Jin2021-01-111-1/+1
| | | | | 1. ParamSpec -> TypeVar for ``typing.Concatenate`` 2. ParamSpec's call signature should align with its documentation. Noticed in GH-24169
* bpo-41559: Documentation for PEP 612 (GH-24000)Ken Jin2021-01-021-7/+8
|
* bpo-41781: Fix typo in internal function name in typing (GH-23957)Ross2020-12-291-3/+3
|
* bpo-42740: Support PEP 604, 612 for typing.py get_args and get_origin (GH-23942)Ken Jin2020-12-291-1/+7
|
* bpo-42740: Fix get_args for PEP 585 collections.abc.Callable (GH-23963)Ken Jin2020-12-281-3/+1
| | | PR 1/2. Needs backport to 3.9.
* bpo-41559: Implement PEP 612 - Add ParamSpec and Concatenate to typing (#23702)kj2020-12-241-41/+168
|
* bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and ↵kj2020-12-131-12/+20
| | | | typing (GH-23060)
* bpo-42059: Fix required/optional keys for TypedDict(..., total=False) (GH-22736)Alex Grönholm2020-12-101-2/+2
|
* bpo-42345: Fix hash implementation of typing.Literal (GH-23383)Yurii Karabas2020-11-191-1/+1
| | | | | | | 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-23/+76
| | | | | | | 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/+2
| | | | | | | | | | | | | | | 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/+16
| | | | | 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-0/+8
| | | | | 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/+15
| | | | | Closes issue41792. Also closes https://github.com/python/typing/issues/751.
* bpo-41428: Implementation for PEP 604 (GH-21515)Maggie Moss2020-09-091-3/+28
| | | | | See https://www.python.org/dev/peps/pep-0604/ for more information. Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
* Fix typo in typing.py (GH-22121)Graham Bleaney2020-09-081-1/+1
| | | This is a trivial PR to fix a typo in a docstring in typing.py. From reverences -> references
* bpo-41521, typing: Rename _PROTO_WHITELIST to _PROTO_ALLOWLIST (#21825)Victor Stinner2020-08-121-3/+3
|
* bpo-41341: Recursive evaluation of ForwardRef in get_type_hints (#21553)wyfo2020-07-221-6/+14
| | | | | | 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-10/+0
| | | Automerge-Triggered-By: @gvanrossum
* bpo-40257: Tweak docstrings for special generic aliases. (GH-20022)Serhiy Storchaka2020-05-101-1/+4
| | | | * Add the terminating period. * Omit module name for builtin types.
* bpo-40397: Fix subscription of nested generic alias without parameters. ↵Serhiy Storchaka2020-05-101-2/+4
| | | | (GH-20021)
* bpo-40397: Remove __args__ and __parameters__ from _SpecialGenericAlias ↵Serhiy Storchaka2020-05-101-80/+87
| | | | (GH-19984)
* bpo-40397: Refactor typing._GenericAlias (GH-19719)Serhiy Storchaka2020-05-071-191/+198
| | | | | | Make the design more object-oriented. Split _GenericAlias on two almost independent classes: for special generic aliases like List and for parametrized generic aliases like List[int]. Add specialized subclasses for Callable, Callable[...], Tuple and Union[...].
* bpo-40389: Improve repr of typing.Optional (#19714)Vlad Serebrennikov2020-04-301-0/+7
|