This function was mistakenly typed as `Callable[[Property], object] |
None`, however the actual function accepts two parameters of type
`Property, value`. The value can be of any type. Strictly speaking, the
type corresponds to the type of the property which is defined at runtime.
Fixes#7103
The goal of this change is to fix the behavior of
`dataclasses.Field`. Several attributes of a `Field` may have a value
of `MISSING` (a sentinel value). As a result, attributes of Field may
be checked against `MISSING` as in
[f for f in fields(obj) if f.default is MISSING]
`default`, `default_factory`, and `kw_only` are the attributes
which may have a value of `MISSING`.
This workaround of defining `_MISSING_TYPE` as an enum, and `MISSING`
as its only member, allows `... | Literal[_MISSING_TYPE.MISSING]` to
be used in type annotations for these attributes. This is very
slightly inaccurate -- primarily in that `_MISSING_TYPE` isn't really
an enum -- but this allows for use in `Literal`.
After PEP 661 (Sentinel Values), there may be a more accurate way of
writing this, but for now this works.
This adjustment is only applied to the attributes of Field, not the
arguments to functions and methods.
Changed typing_extensions.pyi to declare its own private version of `Protocol` and `runtime_checkable` rather than re-exporting the symbols imported from `typing`. This allows pyright to warn users about runtime exceptions when they attempt to use typing.Protocol on versions of Python prior to 3.7.
The types for these class methods were mixed up. The async method
returned an optional `Model`, while the synchronous method returned a
`Future`. It's the other way around.
Fixes#7103
* Update `asyncio.trsock` to reflect methods removed in 3.11
These were all removed in https://bugs.python.org/issue43232
* [pre-commit.ci] auto fixes from pre-commit.com hooks
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
There are quite a few `__iter__` methods in `itertools` that return `self` at runtime. They should do so in the stubs as well.
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>