summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* bpo-40398: Fix typing.get_args() for special generic aliases. (GH-19720)Serhiy Storchaka2020-04-271-1/+3
|
* bpo-40396: Support GenericAlias in the typing functions. (GH-19718)Serhiy Storchaka2020-04-261-5/+18
|
* Fix typo in Lib/typing.py (GH-19717)Nickolena Fisher2020-04-261-1/+1
|
* bpo-40336: Refactor typing._SpecialForm (GH-19620)Serhiy Storchaka2020-04-231-77/+61
|
* bpo-39942:Fix failure in `TypeVar` when missing `__name__` (GH-19616)HongWeipeng2020-04-201-1/+4
| | | https://bugs.python.org/issue39942
* bpo-40257: Improve help for the typing module (GH-19546)Serhiy Storchaka2020-04-181-0/+6
| | | | | | * Show docstring for special forms. * Show docstring for special generic aliases. * Show documentation for __origin__ for generic aliases.
* bpo-40187: Refactor typing.TypedDict. (GH-19372)Serhiy Storchaka2020-04-081-34/+33
|
* bpo-40185: Refactor typing.NamedTuple (GH-19371)Serhiy Storchaka2020-04-081-42/+43
|
* bpo-39481: Implementation for PEP 585 (#18239)Guido van Rossum2020-04-071-3/+4
| | | | | | | | | | | | This implements things like `list[int]`, which returns an object of type `types.GenericAlias`. This object mostly acts as a proxy for `list`, but has attributes `__origin__` and `__args__` that allow recovering the parts (with values `list` and `(int,)`. There is also an approximate notion of type variables; e.g. `list[T]` has a `__parameters__` attribute equal to `(T,)`. Type variables are objects of type `typing.TypeVar`.
* bpo-40182: Remove the _field_types attribute of the NamedTuple class (GH-19368)Serhiy Storchaka2020-04-041-4/+2
|
* bpo-36517: Raise error on multiple inheritance with NamedTuple (GH-19363)Serhiy Storchaka2020-04-041-0/+3
|
* Convert tuples to sets for faster searches (GH-19365)Raymond Hettinger2020-04-041-3/+3
|
* bpo-39572: Document ’total’ flag of TypedDict (GH-18554)ananthan-1232020-02-191-1/+14
|
* bpo-39627: Fix TypedDict totality check for inherited keys (#18503)Vlad Emelianov2020-02-131-13/+20
| | | (Adapted from https://github.com/python/typing/pull/700)
* bpo-39491: Mention Annotated in get_origin() docstring (GH-18379)Jakub Stasiak2020-02-071-2/+2
| | | I forgot to do it in https://github.com/python/cpython/pull/18260.
* bpo-39491: Merge PEP 593 (typing.Annotated) support (#18260)Jakub Stasiak2020-02-051-5/+121
| | | | | | | | | | | | | | | | | | | | | | | | | * bpo-39491: Merge PEP 593 (typing.Annotated) support PEP 593 has been accepted some time ago. I got a green light for merging this from Till, so I went ahead and combined the code contributed to typing_extensions[1] and the documentation from the PEP 593 text[2]. My changes were limited to: * removing code designed for typing_extensions to run on older Python versions * removing some irrelevant parts of the PEP text when copying it over as documentation and otherwise changing few small bits to better serve the purpose * changing the get_type_hints signature to match reality (parameter names) I wasn't entirely sure how to go about crediting the authors but I used my best judgment, let me know if something needs changing in this regard. [1] https://github.com/python/typing/blob/8280de241fd8c8afe727c7860254b753e383b360/typing_extensions/src_py3/typing_extensions.py [2] https://github.com/python/peps/blob/17710b879882454d55f82c2d44596e8e9f8e4bff/pep-0593.rst
* bpo-39493: Fix definition of IO.closed in typing.py (#18265)Shantanu2020-01-301-0/+1
|
* Better runtime TypedDict (GH-17214)Zac Hatfield-Dodds2019-11-241-3/+15
| | | | | This patch enables downstream projects inspecting a TypedDict subclass at runtime to tell which keys are optional. This is essential for generating test data with Hypothesis or validating inputs with typeguard or pydantic.
* bpo-37838: get_type_hints for wrapped functions with forward reference ↵benedwards142019-11-211-1/+5
| | | | | | (GH-17126) https://bugs.python.org/issue37838
* bpo-38407: Add docstrings for typing.SupportsXXX classes. (GH-16644)Serhiy Storchaka2019-10-081-0/+7
|
* bpo-38405: Make nested subclasses of typing.NamedTuple pickleable. (GH-16641)Serhiy Storchaka2019-10-081-1/+1
|
* cleanup ababstractproperty in typing.py (GH-16432)HongWeipeng2019-09-271-8/+15
|
* bpo-38191: Turn warnings into errors in NamedTuple() and TypedDict(). (GH-16238)Serhiy Storchaka2019-09-171-66/+4
|
* bpo-38191: Accept arbitrary keyword names in NamedTuple() and TypedDict(). ↵Serhiy Storchaka2019-09-171-10/+71
| | | | | | | | (GH-16222) This includes such names as "cls", "self", "typename", "_typename", "fields" and "_fields". Passing positional arguments by keyword is deprecated.
* bpo-37953: Fix ForwardRef hash and equality checks (GH-15400)plokmijnuhby2019-09-131-3/+5
| | | | | Ideally if we stick a ForwardRef in a dictionary we would like to reliably be able to get it out again. https://bugs.python.org/issue37953
* bpo-38008: Move builtin protocol whitelist to mapping instead of list (GH-15647)Divij Rajkumar2019-09-121-5/+9
| | | | Fixes https://bugs.python.org/issue38008