| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
|
| |
non-callable members and custom `__subclasshook__` methods (GH-105976) (#106032)
gh-105974: Revert unintentional behaviour change for protocols with non-callable members and custom `__subclasshook__` methods (GH-105976)
(cherry picked from commit 9499b0f138cc53b9a2590350d0b545d2f69ee126)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
|
|
| |
Miscellaneous improvements to the typing docs (GH-105529)
Mostly, these are changes so that we use shorter sentences and shorter paragraphs. In particular, I've tried to make the first sentence introducing each object in the typing API short and declarative.
(cherry picked from commit 8e755923c97d689ba7c7fe8deb50c1b169263264)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
| |
Further improve docs for `typing.Annotated` (GH-105498)
(cherry picked from commit d213c2990f0db62ed39fc5468977f989c2658675)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
|
|
| |
(GH-105369) (#105453)
typing: Improve documentation of generic classes and aliases (GH-105369)
(cherry picked from commit d63a7c3694d5c4484fcaa01c33590b1d4bc2559e)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
|
|
| |
(GH-105434) (#105451)
gh-105430: Remove `typing._Immutable` unused internal helper (GH-105434)
(cherry picked from commit 18309ad94bb1ae0b092f34dc3fd54199876a6ebd)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
|
| |
(#105416)
gh-105286: Further improvements to `typing.py` docstrings (GH-105363)
(cherry picked from commit 9a89f1bf1e7bb819fe7240be779c99a84f47ea46)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
| |
gh-105286: Improve `typing.py` docstrings (#105287)
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
|
|
|
|
|
|
|
|
| |
evaluates to `False` (GH-105281) (#105318)
gh-105280: Ensure `isinstance([], collections.abc.Mapping)` always evaluates to `False` (GH-105281)
(cherry picked from commit 08756dbba647440803d2ba4545ba0ab2f0cdfe1c)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
|
|
| |
(GH-105239) (#105316)
gh-105237: Allow calling `issubclass(X, typing.Protocol)` again (GH-105239)
(cherry picked from commit cdfb201bfa35b7c50de5099c6d9078c806851d98)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
|
| |
`_ProtocolMeta.__subclasscheck__` (GH-105152) (#105160)
(cherry picked from commit c05c31db8c9dfd708b9857bb57f8e5f3ce40266d)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
| |
(cherry picked from commit 46857d0b2a2ac6aeb6dcce2bf2c92ddf4abe7496)
Co-authored-by: Tomas R <tomas.roun8@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
`Generic` (GH-104939) (#104941)
gh-104935: typing: Fix interactions between `@runtime_checkable` and `Generic` (GH-104939)
---------
(cherry picked from commit 2b7027d0b2ee2e102a24a0da27d01b8221f9351c)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
|
|
|
| |
(GH-104827) (#104841)
gh-104797: Allow Protocols to inherit from collections.abc.Buffer (GH-104827)
(cherry picked from commit c0ab7d401c736c37bf4462eef7c7d69fef8fab93)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
| |
|
|
|
|
|
| |
of protocols (#104622)
Don't set special protocol attributes on non-protocol subclasses of protocols
|
|
|
|
|
| |
`isinstance()` influence whether `issubclass()` raises an exception (#104559)
Co-authored-by: Carl Meyer <carl@oddbird.net>
|
|
|
| |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
| |
that use PEP 695 (#104556)
Fixes #104555
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This implements PEP 695, Type Parameter Syntax. It adds support for:
- Generic functions (def func[T](): ...)
- Generic classes (class X[T](): ...)
- Type aliases (type X = ...)
- New scoping when the new syntax is used within a class body
- Compiler and interpreter changes to support the new syntax and scoping rules
Co-authored-by: Marc Mueller <30130371+cdce8p@users.noreply.github.com>
Co-authored-by: Eric Traut <eric@traut.com>
Co-authored-by: Larry Hastings <larry@hastings.org>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
| |
|
| |
|
| |
|
|
|
|
| |
This does nothing.
|
|
|
|
| |
(#104335)
|
|
|
|
|
|
|
|
|
| |
I'd like to make the fact that this does nothing at runtime
really obvious, since I suspect this is unintuitive for users who are
unfamiliar with static type checking.
I thought of this because of
https://discuss.python.org/t/add-arg-check-type-to-types/26384
wherein I'm skeptical that the user really did want `assert_type`.
|
| |
|
|
|
|
| |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
|
|
|
|
|
|
| |
Annotated}` (#103405)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Kirill <80244920+Eclips4@users.noreply.github.com>
|
| |
|
|
|
|
| |
protocol class creation time, not during `isinstance()` checks (#103160)
|
|
|
|
| |
(#103159)
|
|
|
|
| |
`typing._ProtocolMeta.__instancecheck__` (#103034)
|
|
|
| |
Improve performance of `isinstance()` checks against runtime-checkable protocols
|
|
|
|
|
| |
`_ProtocolMeta.__instancecheck__` (#103141)
Speed up `isinstance()` calls against runtime-checkable protocols
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
`ParamSpec` substitution (#102808)
Previously, this used to fail:
```py
from typing import *
T = TypeVar("T")
P = ParamSpec("P")
class X(Generic[P]):
f: Callable[P, int]
Y = X[[int, T]]
Z = Y[str]
```
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
|
| |
(#102752)
Remove `if` condition in `_collections_abc._type_repr` that's no longer needed, bringing it in sync with `typing._type_repr`.
|
|
|
| |
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
| |
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
|
|
|
|
| |
(#101031)
|
|
|
|
|
| |
(GH-99520)
Also updates calls in collections, doctest, enum, and typing modules to use _getframemodulename first when available.
|
|
|
|
| |
In the docstring of `ParamSpec`, the name of `P = ParamSpec('P')` was
mistakenly written as `'T'`.
|
| |
|
|
|
|
| |
typing.py lru_cache (#98591)
|
|
|
|
|
|
|
|
|
|
|
| |
TypeVarTuple (GH-99412)
* Fix substitution of TypeVarTuple and ParamSpec together in user generics.
* Fix substitution of ParamSpec followed by TypeVarTuple in generic aliases.
* Check the number of arguments in substitution in user generics containing a
TypeVarTuple and one or more TypeVar.
|
|
|
|
|
| |
Fix subscription of type aliases containing bare generic types or types
like TypeVar: for example tuple[A, T][int] and tuple[TypeVar, T][int],
where A is a generic type, and T is a type variable.
|
| |
|
| |
|
| |
|
|
|
|
|
| |
* fix typo - double spelled word 'use'
* change methods names to the infinitive form
|
|
|
| |
Co-authored-by: Serhiy Storchaka <3659035+serhiy-storchaka@users.noreply.github.com>
|