typing
typing copied to clipboard
Python static typing home. Hosts the documentation and a user help forum.
from https://github.com/python/mypy/issues/11389 ## Feature in kotlin, you can omit a generic from a type annotation when you don't care what its value is: ```kotlin class Foo fun foo(value: Foo) {}...
I believe there is a use case for generic inference that doesn't get as wide as possible. Look at this example of an assertion function, you would never want to...
### Discussed in https://github.com/python/typing/discussions/832 (Trying the "Open issue from discussion" feature.) Now: - [x] Announce in https://gitter.im/python/typing - [x] Add a note to typeshed's README (python/typeshed#5901) - [ ] Add...
Currently `issubclass` cannot be used for `runtime_checkable` protocols with data members, because those attributes could be set in `__init__`. I propose to relax this restriction to allow protocols with `ClassVar`...
Suppose we have: ``` T = TypeVar('T') Element = tuple[T] def fn(elements: tuple[Element, ...]): ... ``` The problem is that `T` is forced to be the same for every element,...
Defining the two variances of a TypeVar is rather verbose: ```python T_co = TypeVar("T_co", covariant=True) T_contra = TypeVar("T_contra", contravariant=True) ``` So I propose an alternative syntax, similar to that of...
**Feature** A concise way to hint that a sequence of homogenous types is a set length. i.e The items in the sequence are all of the same type, the sequence...
Hi, I want to create a type alias that simply wraps a tuple into `Annotated`. [PEP 593](https://www.python.org/dev/peps/pep-0593) I want to be able to write ```python SpecialReturn[int, bool, str] ``` And...
Generic information are lost with classes `__mro__`. But it could be useful to have it, especially for #776 implementation. `typing` module could integrate a `generic_mro` function in order to retrieve...
When it comes to generic classes, type annotations retrieved with `get_type_hints` are not really easy to use, as in the following example: ```python from typing import Generic, TypeVar, get_type_hints T...