summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-44353: Correct docstring for `NewType` (#29785)Alex Waygood2021-11-261-1/+1
| | | The docstring for `typing.NewType` is no longer strictly accurate, now that `NewType` is a class, rather than a function
* bpo-45679: Fix caching of multi-value typing.Literal (GH-29334)Serhiy Storchaka2021-10-311-6/+5
| | | Literal[True, 2] is no longer equal to Literal[1, 2].
* bpo-45489: Update ForwardRef to support | operator. (GH-28991)Dong-hee Na2021-10-161-0/+6
|
* bpo-45166: fixes `get_type_hints` failure on `Final` (GH-28279)Nikita Sobolev2021-09-251-9/+20
| | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-45121: Fix RecursionError when calling Protocol.__init__ from a ↵Yurii Karabas2021-09-081-0/+5
| | | | subclass' __init__ (GH-28206)
* bpo-45081: Fix __init__ method generation when inheriting from Protocol ↵Yurii Karabas2021-09-021-12/+24
| | | | | (GH-28121) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-44524: Don't modify MRO when inheriting from typing.Annotated (GH-27841)Ken Jin2021-08-251-1/+6
|
* bpo-44524: Do not set _name of _SpecialForm without need (GH-27861)Serhiy Storchaka2021-08-211-11/+8
| | | | | Because setting non-empty _name affects behavior of other code. In most cases __name__ can be derived from __origin__.__name__.
* bpo-44524: Fix cryptic TypeError message when trying to subclass special ↵Yurii Karabas2021-08-181-0/+3
| | | | | forms in `typing` (GH-27710) This was a Python 3.9 regression.
* bpo-44524: Fix an issue wherein `_GenericAlias._name` was not properly set ↵Bas van Beek2021-08-061-7/+16
| | | | | | for specialforms (GH-27614) Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* bpo-44801: Check arguments in substitution of ParamSpec in Callable (GH-27585)Serhiy Storchaka2021-08-041-8/+18
|
* bpo-44806: Fix __init__ in subclasses of protocols (GH-27545)Serhiy Storchaka2021-08-021-2/+10
| | | | Non-protocol subclasses of protocol ignore now the __init__ method inherited from protocol base classes.
* bpo-44793: Fix checking the number of arguments when subscribe a generic ↵Serhiy Storchaka2021-08-021-6/+9
| | | | | | | | 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.
* bpo-44747: Refactor usage of sys._getframe at typing module (#27387)Yurii Karabas2021-07-301-21/+7
| | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-44761: Change default value of NewType __module__ attr (GH-27406)Yurii Karabas2021-07-301-4/+6
|
* bpo-44732: Rename types.Union to types.UnionType (#27342)Hasan2021-07-261-11/+11
| | | | Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-44676: Serialize the union type using only public API (GH-27323)Serhiy Storchaka2021-07-241-2/+2
| | | | Remove also the _from_args() constructor.
* 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)