Closed
Description
The current type annotations have a number of issues:
_DeferredResultT
is contravariant, which is confusing and inaccurate; it should be invariantaddCallback
,addErrback
, andaddBoth
don't check their callbacks' signatures at all; you don't have to accept aFailure
for the latter two, to say nothing of the rest of the signature.Deferred.fromFuture
uses an unspecialized generic (see Improve type annotation fortwisted.internet.defer.Deferred.fromFuture
#11753)maybeDeferred
incorrectly returns aDeferred[Deferred[X]]
if its function returns a deferred
Some of these are due to new features in Mypy that have come out since the type hints were added, some are simply errors in the initial implementation, but we should give it a new pass to address both and have more correct stubs. (Some issues are not possible to fix, such as addCallabcks
having multiple ParamSpec
signatures in a way that mypy does not yet allow expressing.)