summaryrefslogtreecommitdiffstats
path: root/Lib/typing.py
Commit message (Collapse)AuthorAgeFilesLines
* bpo-46333: Honor `module` parameter in ForwardRef (GH-30536)aha792022-02-171-2/+3
| | | | | | | | | 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/+11
| | | | | | Closes python/typing#981 https://bugs.python.org/issue46066
* bpo-46333: include `module` in `ForwardRef.__repr__` (#31283)aha792022-02-121-1/+5
| | | | | | | | 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-46475: Add typing.Never and typing.assert_never (GH-30842)Jelle Zijlstra2022-02-081-4/+60
|
* bpo-46676: Make ParamSpec args and kwargs equal to themselves (GH-31203)Gregory Beauregard2022-02-081-0/+10
|
* bpo-46534: Implement PEP 673 Self in typing.py (GH-30924)James Hilton-Balfe2022-02-071-1/+23
| | | | Co-authored-by: Pradeep Kumar Srinivasan <gohanpra@gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* bpo-46589: Improve documentation for typing._GenericAlias (GH-31026)Matthew Rahtz2022-02-071-32/+110
| | | (These should arguably be docstrings per convention in the rest of the file, but it doesn't really matter.)
* bpo-46655: allow stringized TypeAlias with get_type_hints (GH-31156)Gregory Beauregard2022-02-061-1/+1
|
* Fix __init_subclass__ using self instead of class (#31135)Gregory Beauregard2022-02-051-1/+1
|
* bpo-46414: Add typing.reveal_type (#30646)Jelle Zijlstra2022-02-021-0/+21
| | | | Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
* bpo-46560: Fix a typo in `typing.ParamSpec's` doc string (GH-30995)Zackery Spytz2022-01-281-1/+1
|
* bpo-46553: allow bare typing.ClassVar annotations (#30983)Gregory Beauregard2022-01-281-1/+1
| | | | | These are used in the wild and covered by dataclasses unit tests. Several static type checkers support this pattern.
* bpo-44791: Fix substitution of ParamSpec in Concatenate with different ↵Serhiy Storchaka2022-01-271-1/+11
| | | | | | | | | parameter expressions (GH-27518) * Substitution with a list of types returns now a tuple of types. * Substitution with Concatenate returns now a Concatenate with concatenated lists of arguments. * Substitution with Ellipsis is not supported.
* bpo-46539: Pass status of special typeforms to forward references (GH-30926)Gregory Beauregard2022-01-271-3/+3
| | | | | | | | | Previously this didn't matter because there weren't any valid code paths that could trigger a type check with a special form, but after the bug fix for `Annotated` wrapping special forms it's now possible to annotate something like `Annotated['ClassVar[int]', (3, 4)]`. This change would also be needed for proposed future changes, such as allowing `ClassVar` and `Final` to nest each other in dataclasses.
* bpo-46491: Allow Annotated on outside of Final/ClassVar (GH-30864)Gregory Beauregard2022-01-251-4/+4
| | | | | We treat Annotated type arg as class-level annotation. This exempts it from checks against Final and ClassVar in order to allow using them in any nesting order. Automerge-Triggered-By: GH:gvanrossum
* bpo-46470: remove unused branch from `typing._remove_dups_flatten` (GH-30780)Nikita Sobolev2022-01-241-2/+0
| | | The branch was a remnant of old 3.6 typing.Union implementation.
* bpo-46342: make @typing.final introspectable (GH-30530)Jelle Zijlstra2022-01-121-1/+10
| | | Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
* bpo-46244: Remove __slots__ from typing.TypeVar, .ParamSpec (#30444)Arie Bovenberg2022-01-101-6/+0
| | | | | | | | | | | * add missing __slots__ to typing._TypeVarLike * add news entry * remove slots from _TypeVarLike base classes * cleanup diff * fix broken link in blurb
* bpo-45755: [typing] Reveal class attributes of generic in generic aliases in ↵Ken Jin2021-12-161-0/+3
| | | | `dir()` (GH-29962)
* 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