| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
This is a trivial PR to fix a typo in a docstring in typing.py. From reverences -> references.
(cherry picked from commit 84ef33c5117acd9867781135a9aeb62052432e8a)
Co-authored-by: Graham Bleaney <gbleaney@gmail.com>
Automerge-Triggered-By: @Mariatta
|
|
|
|
|
|
| |
(GH-19720) (GH-19857)
(cherry picked from commit 6292be7adf247589bbf03524f8883cb4cb61f3e9)
|
|
|
|
|
|
| |
https://bugs.python.org/issue39942
(cherry picked from commit a25a04fea5446b1712cde0cff556574be139285a)
Co-authored-by: HongWeipeng <hongweichen8888@sina.com>
|
|
|
|
|
| |
(cherry picked from commit ab6423fe2de0ed5f8a0dc86a9c7070229326b0f0)
Co-authored-by: ananthan-123 <ananthakrishnan15.2001@gmail.com>
|
|
|
|
|
| |
(cherry picked from commit 2e6569b6692298fcc9aae0df3eb3181adb2a5099)
Co-authored-by: Shantanu <hauntsaninja@users.noreply.github.com>
|
|
|
|
|
|
|
|
| |
(GH-17126)
https://bugs.python.org/issue37838
(cherry picked from commit 0aca3a3a1e68b4ca2d334ab5255dfc267719096e)
Co-authored-by: benedwards14 <53377856+benedwards14@users.noreply.github.com>
|
|
|
|
|
| |
(cherry picked from commit 8252c52e57283515ace5d4251584255dc5c60eb5)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
| |
(cherry picked from commit 13abda41003daf599587991d8291f0dacf6e9519)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
| |
(cherry picked from commit 6ce03ec627680ce0829a5b3067fab7faed21b533)
Co-authored-by: HongWeipeng <961365124@qq.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
(GH-16222)
This includes such names as "cls", "self", "typename", "_typename",
"fields" and "_fields".
Passing positional arguments by keyword is deprecated.
(cherry picked from commit 2bf31ccab3d17f3f35b42dca97f99576dfe2fc7d)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
|
|
|
|
|
|
|
|
| |
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
(cherry picked from commit e082e7cbe4a934b86f7a07354d97d4e14a9dd46a)
Co-authored-by: plokmijnuhby <39633434+plokmijnuhby@users.noreply.github.com>
|
|
|
|
|
|
| |
Fixes https://bugs.python.org/issue38008
(cherry picked from commit 692a0dc91597b7fb350383b633dc4d044cbd360e)
Co-authored-by: Divij Rajkumar <drajkuma1@gmail.com>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
(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.
|
|
|
| |
https://bugs.python.org/issue36983
|
|
|
|
|
| |
I tried to get rid of the `_ProtocolMeta`, but unfortunately it didn'y work. My idea to return a generic alias from `@runtime_checkable` made runtime protocols unpickleable. I am not sure what is worse (a custom metaclass or having some classes unpickleable), so I decided to stick with the status quo (since there were no complains so far). So essentially this is a copy of the implementation in `typing_extensions` with two modifications:
* Rename `@runtime` to `@runtime_checkable` (plus corresponding updates).
* Allow protocols that extend `collections.abc.Iterable` etc.
|
|
|
|
| |
The implementation is straightforward and essentially is just copied from `typing_extensions`.
|
|
|
|
| |
The implementation is straightforward and essentially is just copied from `typing_extensions`.
|
|
|
|
| |
The implementation is straightforward, it just mimics `ClassVar` (since the latter is also a name/access qualifier, not really a type). Also it is essentially copied from `typing_extensions`.
|
|
|
|
| |
In order to support typing checks calling hex(), oct() and bin() on user-defined classes, a SupportIndex protocol is required. The ability to check these at runtime would be good to add for completeness sake. This is pretty much just a copy of SupportsInt with the names tweaked.
|
|
|
|
|
|
| |
Also, deprecate the *_field_types* attributes which duplicated the information in *\__annotations__*.
https://bugs.python.org/issue36320
|
| |
|
| |
|
| |
|
|
|
| |
"explicitelly" → "explicitly"
|
|
|
| |
"can be used do declare" → "can be used to declare"
|
| |
|
|
|
|
| |
Pickles of type variables and subscripted generics are now future-proof
and compatible with older Python versions.
|
| |
|
| |
|
| |
|
| |
|
|
|
|
| |
This also fixes https://bugs.python.org/issue33420
|
| |
|
|
|
|
| |
This removes a hack and replaces it with a proper
mapping {'list': 'List', 'dict': 'Dict', ...}.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
copy and pickle (GH-6216)
This also fixes python/typing#512
This also fixes python/typing#511
As was discussed in both issues, some typing forms deserve to be treated
as immutable by copy and pickle modules, so that:
* copy(X) is X
* deepcopy(X) is X
* loads(dumps(X)) is X # pickled by reference
This PR adds such behaviour to:
* Type variables
* Special forms like Union, Any, ClassVar
* Unsubscripted generic aliases to containers like List, Mapping, Iterable
This not only resolves inconsistencies mentioned in the issues, but also
improves backwards compatibility with previous versions of Python
(including 3.6).
Note that this requires some dances with __module__ for type variables
(similar to NamedTuple) because the class TypeVar itself is define in typing,
while type variables should get module where they were defined.
https://bugs.python.org/issue32873
|
| |
|
|
|
|
| |
This PR re-designs the internal typing API using the new PEP 560 features.
However, there are only few minor changes in the public API.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
(#3582)
This makes the default behavior (without specifying `globalns` manually) more
predictable for users, finds the right globalns automatically.
Implementation for classes assumes has a `__module__` attribute and that module
is present in `sys.modules`. It does this recursively for all bases in the
MRO. For modules, the implementation just uses their `__dict__` directly.
This is backwards compatible, will just raise fewer exceptions in naive user
code.
Originally implemented and reviewed at https://github.com/python/typing/pull/470.
|
|
|
|
| |
* Copy changes to typing from upstream repo
* Add NEWS entry
|
|
|
|
|
|
|
| |
This PR contains two updates to typing module:
- Support ContextManager on all versions (original PR by Jelle Zijlstra).
- Add generic AsyncContextManager.
|
|
|
|
|
| |
- Add NoReturn type
- Use WrapperDescriptorType (original PR by Jim Fasarakis-Hilliard)
- Minor bug-fixes
|
| |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
various updates from upstream python/typing repo:
- Added typing.Counter and typing.ChainMap generics
- More flexible typing.NamedTuple
- Improved generic ABC caching
- More tests
- Bugfixes
- Other updates
* Add Misc/NEWS entry
* Add issue number
|
| |
|
| |
|