-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#11772 Correct deferred annotations #11770
Conversation
Co-authored-by: Jean-Paul Calderone <exarkun@twistedmatrix.com>
for more information, see https://pre-commit.ci
…ier/twisted into babolivier/fromfuture_annotation
Note that this is stacked on top of #11767 since it requires some newer mypy features. |
…-deferred-annotations
It's also stacked on top of #11754 but it supersedes that PR since there are a lot of follow-on changes from there |
please review |
The test failure is a result of #11843 and should be addressed by its merge. |
please review |
'comment' reviews really should not take it out of the review queue :) |
And, indeed, it was. |
True... but this is how GitHub works ... if you request a review from a team, as soon as a team member makes a comment on the PR, the team is removed. This is one reason why we have the "needs-review" label, to have better control. In the future I will try to manually re-request a review from the team. And in the future, maybe the robot can do this for us... if a only a "comment" review is added, re-add the team in the list of reviewers. |
this is a big PR but I can't see any problems with it. I note that two core developers have already reviewed most of the changes. |
I will interpret this as an "approve" review, make the changes and land. |
Ah, reviewing this now I can see why you might be confused, but the change doesn't modify behavior (and thus doesn't belong in the news fragment) and this style isn't sufficiently interesting in its own context to warrant an explanation. The change could perhaps use one though, so I'll explain here: Deferreds are an unusual kind of object because their type changes when you call methods on them. Technically speaking, this is impossible for a type-checker like Mypy to actually validate. Like, consider this: def mutate(d: Deferred[int]) -> Deferred[str]:
d.addCallback(str)
return d
...
x: Deferred[int] = deferredIntReturner()
mutate(x)
mutate(x) There's no way that mypy could see that the second call to However, idiomatically, it's reasonable to work this way and callers sharing In order to make the fiction of enforced-single-use- |
Scope and purpose
Fixes #11772
Fixes #11753
Add a few words about why this PR is needed and what is its scope.
If the associate ticket(s) fully explain the need you can just refer to it/them.
Add any comments about trade-offs (if any) made in this PR and the reasoning behind them.
Add mentions of things that are not covered here and are planed to be done in separate PRs.
Contributor Checklist:
This process applies to all pull requests - no matter how small.
Have a look at our developer documentation before submitting your Pull Request.
Below is a non-exhaustive list (as a reminder):
please review
.Our bot will trigger the review process, by applying the pending review label
and requesting a review from the Twisted dev team.