typeshed
typeshed copied to clipboard
Collection of library stubs for Python, with static types
We recently hit an error using `@wraps` on a class method in Trio: https://github.com/python-trio/trio/issues/2775#issuecomment-1702892474 when checked with pyright. It works fine on mypy, but I'm guessing they might be special-casing...
I'm not entirely sure this is a bug in the type stub. It depends on the interpretation of ParamSpec when used with methods. This is related to the discussion [here](https://github.com/python/typing/discussions/946)...
Support inheritance for `relativedelta.__rsub__` by setting the `TypeVar` upper bound to `datetime.date` (parent of `datetime.datetime`), instead of having both those as constraint. Resolved #11462
Given this sample case: ```python from datetime import datetime from dateutil.relativedelta import relativedelta class MyDateTime(datetime): pass d = MyDateTime.now() x = d - relativedelta(days=1) print(type(x)) # reveal_type(x) ``` results in...
Closes https://github.com/python/typeshed/issues/11259
This adds the final little bibs and bobs that were still missing. I'll readily admit I went a little bit insane writing the stubs for `webob.dec.wsgify`, so reviewing this one...
Some of the added stubs are taken from [here](https://github.com/hmc-cs-mdrissi/tensorflow_stubs/blob/main/stubs/tensorflow/keras/layers.pyi).
This PR adds stubs for the [wurlitzer](https://github.com/minrk/wurlitzer) package.
```py from collections.abc import Callable from types import NotImplementedType class MyClass: pass callable_union: Callable | NotImplementedType reveal_type(callable_union) if not isinstance(callable_union, NotImplementedType): reveal_type(callable_union) # Gets narrowed correctly class_union: MyClass | NotImplementedType...
The first commit only reorder names to be closer to implementation. Making it easier to compare with the original code, and reducing changes in the following commit. Whilst still avoiding...