typing icon indicating copy to clipboard operation
typing copied to clipboard

Python static typing home. Hosts the documentation and a user help forum.

Results 224 typing issues
Sort by recently updated
recently updated
newest added

**The Problem** At runtime, `TYPE_CHECKING` is always `False`, only type checkers assume it is `True`. Therefore, `if TYPE_CHECKING` blocks are only parsed, but never evaluated by the Python interpreter. Since...

topic: feature

The [typing spec](https://typing.readthedocs.io/en/latest/spec/special-types.html#noreturn) currently states: > The `NoReturn` type is only valid as a return annotation of functions, and considered an error if it appears in other positions. This is...

topic: documentation

Currently a declaration `sign: Literal[-1, +1]` is not allowed, because the spec forbids expressions as literal values. There is an explicit exception for unary minus, but no corresponding exception for...

topic: feature

There's a subtle dance around `__add__`, `__radd__`, and `NotImplemented`. While most of the rules are in the language spec, I think we haven't specified carefully what the signature should be...

topic: typing spec

Consider this real code: ```python from typing import SuperKwargs class InferenceManager(Generic[T]): @override def __init__(self, *, default_trajectory: T, progress_manager: None | ProgressManager, wandb_run: None | Run ) -> None: super().__init__() self._progress_manager...

topic: feature

Suppose we have the following code: ```py T_co = TypeVar("T_co", covariant=True) class CanProduce(Protocol[T_co]): def produce(self) -> T_co: ... T_in = TypeVar("T_in") U = TypeVar("U") @dataclass class Container(Generic[T_in]): value: T_in def...

topic: feature

I can't find anywhere in the current spec where we specify how inheriting from `Any` should work. I've heard that it's relied upon in typeshed. (E.g. `class pmem(Any)` in gevent...

topic: typing spec

The typing spec should provide guidance on how type checkers should handle `__exit__` annotations. This method is special because `__exit__` methods can suppress exceptions, and whether or not they do...

topic: documentation
topic: typing spec

Split from #1000. ---- I have a similar use case with [Ariadne middleware](https://ariadnegraphql.org/docs/middleware) functions, but with `kwargs`. In Ariadne, a "resolver" function takes two positional arguments and a varying number...

topic: feature