| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
| |
(cherry picked from commit 81fb3548be5a18bf40a6f4505a02cc7fb72c9c34)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
(cherry picked from commit 6e7b813195f9bd6a2a15c1f00ef2c0180f6c751a)
Co-authored-by: aha79 <34090357+aha79@users.noreply.github.com>
|
|
|
|
|
| |
(cherry picked from commit d2d1d49eaccaa83eb8873ba15f2fc9562143bc56)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
|
|
|
| |
(GH-31045)
(cherry picked from commit 4c0612ad00ba45dbea2a86f7db6d21546cf243f8)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Automerge-Triggered-By: GH:Fidget-Spinner
|
|
|
|
|
|
|
|
|
|
|
| |
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.
(cherry picked from commit ced50051bb752a7c1e616f4b0c001f37f0354f32)
Co-authored-by: Gregory Beauregard <greg@greg.red>
|
|
|
|
|
| |
(cherry picked from commit d0c690b5f85c679de6059cf353fe0524e905530e)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit e1abffca45b60729c460e3e2ad50c8c1946cfd4e)
Co-authored-by: Gregory Beauregard <greg@greg.red>
|
|
|
|
|
| |
(cherry picked from commit 263c0dd16017613c5ea2fbfc270be4de2b41b5ad)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
|
| |
(GH-30663) (GH-30692)
(cherry picked from commit 32398294fb3fcf4ee74da54722fd0221c4e6cb74)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
| |
(cherry picked from commit 1de60155d5d01be2924e72fb68dd13d4fd00acd7)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
| |
Literal[True, 2] is no longer equal to Literal[1, 2]..
(cherry picked from commit 634984d7dbdd91e0a51a793eed4d870e139ae1e0)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
| |
(GH-28570)
Co-authored-by: Dong-hee Na <donghee.na92@gmail.com>
(cherry picked from commit f56268a2cd38b3fe2be1e4361d3d8b581e73559b)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
| |
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>.
(cherry picked from commit 784905dbeff68cf788bbeefe0a675af1af04affc)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
| |
subclass' __init__ (GH-28206) (GH-28233)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
| |
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>
Co-authored-by: Germán Méndez Bravo <german.mb@gmail.com>
Co-authored-by: Łukasz Langa <lukasz@langa.pl>
|
|
|
|
|
|
|
| |
raise TypeError (GH-26067)" (GH-26077)
Reverts python/cpython#26075
Automerge-Triggered-By: GH:gvanrossum
|
|
|
|
|
|
|
|
|
| |
TypeError (GH-26067) (GH-26075)
(cherry picked from commit c40486a)
Co-authored-by: Yurii Karabas 1998uriyyo@gmail.com
Automerge-Triggered-By: GH:gvanrossum
|
|
|
|
|
|
| |
PR 1/2. Needs backport to 3.9.
(cherry picked from commit 4140f10a16f06c32fd49f9e21fb2a53abe7357f0)
Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
|
|
|
|
|
|
|
| |
(GH-22736) (GH-23747)
(cherry picked from commit 67b769f5157c9dad1c7dd6b24e067b9fdab5b35d)
Co-authored-by: Alex Grönholm <alex.gronholm@nextday.fi>
|
|
|
|
|
| |
collections.abc and typing (GH-23765)
Backport of GH-23060.
|
|
|
|
|
|
|
|
|
|
| |
Fix hash implementation of `typing.Literal`.
Update docs regarding `typing.Litaral` caching.
Base implementation was done in PR GH-23294.
(cherry picked from commit 1b54077ff6f5c1379e097e9f8e8648da9826d6ec)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(GH-23335)
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.
(cherry picked from commit f03d318ca42578e45405717aedd4ac26ea52aaed)
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit 1f7dfb277e5b88cddc13e5024766be787a3e9127)
Co-authored-by: kj <28750310+Fidget-Spinner@users.noreply.github.com>
|
|
|
|
|
|
|
|
| |
The issue raised by recursive evaluation is infinite recursion with
recursive types. In that case, only the first recursive ForwardRef is
evaluated.
(cherry picked from commit 653f420b53a3aa87316cef59de8d3f5d9e11deb4)
Co-authored-by: wyfo <joperez@hotmail.fr>
|
|
|
|
|
|
| |
Automerge-Triggered-By: @gvanrossum
(cherry picked from commit 7fed75597fac11f9a6c769e2b6c6548fe0e4049d)
Co-authored-by: Zackery Spytz <zspytz@gmail.com>
|
|
|
|
| |
(GH-20021)
|
| |
|
| |
|
| |
|
| |
|
|
|
| |
https://bugs.python.org/issue39942
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
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`.
|
| |
|
| |
|
| |
|
|
|
| |
(Adapted from https://github.com/python/typing/pull/700)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
(GH-17126)
https://bugs.python.org/issue37838
|
| |
|
| |
|
|
|
|
|
|
|
|
| |
(GH-16222)
This includes such names as "cls", "self", "typename", "_typename",
"fields" and "_fields".
Passing positional arguments by keyword is deprecated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
self.assertEquals() is deprecated.
```
./python -We -m test test_typing
Run tests sequentially
0:00:00 load avg: 0.23 [1/1] test_typing
test test_typing failed -- Traceback (most recent call last):
File "/home/lubuntu2/cpython/Lib/test/test_typing.py", line 2382, in test_forward_equality_gth
self.assertEquals(Union[c1, c1_gth], Union[c1])
File "/home/lubuntu2/cpython/Lib/unittest/case.py", line 1390, in deprecated_func
warnings.warn(
DeprecationWarning: Please use assertEqual instead.
test_typing failed
== Tests result: FAILURE ==
1 test failed:
test_typing
Total duration: 140 ms
Tests result: FAILURE
```
https://bugs.python.org/issue37953
|
|
|
|
|
| |
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
|
|
|
|
| |
Fixes https://bugs.python.org/issue38008
|
|
|
|
|
|
| |
This adds a regression test for the issue found in the Python 2 backport, see https://github.com/python/typing/issues/656
https://bugs.python.org/issue28556
|
|
|
| |
This test "works" if things are run in the right order, so it's better to use @skip than @expectedFailure here.
|
|
|
|
|
|
|
|
|
|
| |
(GH-13685)
This is an old feature request that appears from time to time. After a year of experimenting with various introspection capabilities in `typing_inspect` on PyPI, I propose to add these two most commonly used functions: `get_origin()` and `get_args()`. These are essentially thin public wrappers around private APIs: `__origin__` and `__args__`.
As discussed in the issue and on the typing tracker, exposing some public helpers instead of `__origin__` and `__args__` directly will give us more flexibility if we will decide to update the internal representation, while still maintaining backwards compatibility.
The implementation is very simple an is essentially a copy from `typing_inspect` with one exception: `ClassVar` was special-cased in `typing_inspect`, but I think this special-casing doesn't really help and only makes things more complicated.
|