typing
typing copied to clipboard
Python static typing home. Hosts the documentation and a user help forum.
support something like this ```python class A[T]: def __init__(self, t: T): self.t = t class B: def x[TA: A](self, a: TA) -> TA.T: return a.t ```
… accessing a generic attribute on a class when a subtype could provide specialization for that generic attribute. Pyright recently made a modification to eliminate a false positive error in...
This PR clarifies the typing spec around named tuple fields and adds a few conformance test cases: - fields are not being allowed to begin with underscore (and its interaction...
```python from __future__ import annotations from typing import Callable, Generator, LiteralString, Self, Tuple class Callbacks[**P, T]: def __init__(self, funcs: Generator[Callable[P, T]]): self.funcs = funcs def __call__(self, *args: P.args, **kwargs: P.kwargs):...
The classes `typing.IO`, `typing.BinaryIO`, and `typing.TextIO` look like they want to be Protocols or ABCs, but in fact they are defined as regular generic classes, both at runtime and in...
The problem I'm having is that the `type` doesn't support `ParamSpec`, so I can't use that to enforce `args` and `kwargs`, in the same way as as `Callable`. I'm not...
The inference of generic types for classes in most type-checkers assume that all the generic types can be inferred from the parameters to `__init__`. This is not always the case....
# Description There are a few code examples in the docs which import things from `typing_extensions` that are by now available in Python's `typing` standard library module: List https://github.com/python/typing/blob/3149e8ce32ff5bb3c1afd01467d2d7b1f5b64c95/docs/guides/unreachable.rst?plain=1#L57 https://github.com/python/typing/blob/3149e8ce32ff5bb3c1afd01467d2d7b1f5b64c95/docs/reference/generics.rst?plain=1#L655...
Fixes #1986.
Added missing tests to typeddicts_operations.py based on the current state of https://typing.python.org/en/latest/spec/typeddict.html#supported-and-unsupported-operations Stumbled upon type checkers having a different behaviour for `typed_dict[str]`, investigated the spec and the spec is clear...