typing
typing copied to clipboard
Python static typing home. Hosts the documentation and a user help forum.
Not sure if it's still required-required by pytype - I haven't investigated, but wanted to document as it is the current conformance requirement. Source: https://github.com/python/typing/blob/0b9fed83ee2ac10aeac187d4182ae949f9fc25f0/conformance/src/type_checker.py#L313-L318
The context is in example 2 from https://github.com/python/typing/pull/1918 It doesn't make sense to enforce this requirement for just `**kwargs` but not any other arguments annotated with a TypedDict, and additionally,...
Hello, Consider the following, where `lock` aims at making provided argument immutable. ```python @dataclass class Works: foo: Mapping def lock(self) -> None: self.foo = MappingProxyType(self.foo) ``` It works great with...
I'm sure that there are other use cases for this, but the main one that comes to mind is inferring the type of function parameters. It is common that you...
datetime.datetime objects created with timezone information cannot be compared to datetime objects without timezone information. This error comes up ``` TypeError: can't compare offset-naive and offset-aware datetimes ``` I believe...
In [the subsection describing singletons in unions](https://typing.python.org/en/latest/spec/concepts.html#support-for-singleton-types-in-unions), widely used `object()` example is described as a singleton, but it isn't one. It should be clearly stated that the problem for typing...
The language of the typing spec indicates that the `@final` decorator may be used with properties: > The method decorator version may be used with all of instance methods, class...
I'm looking the way to interfere existing types explicitly, like `typeof` / `keyof` in `Typescript` I have 2 use cases: * existing function definition -> `Callable[...]` * dataclass `__init__` signature...
## Motivation Some framework packages (like [pytest](https://docs.pytest.org/en/stable/example/markers.html), [polars](https://docs.pola.rs/api/python/stable/reference/api.html), [xarray](https://docs.xarray.dev/en/latest/internals/extending-xarray.html), …) have APIs that allow plugin packages to define attributes on their classes/singletons using some registration function, e.g.: ```py import pytest...