-
Notifications
You must be signed in to change notification settings - Fork 85
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
First pass at mypy for sydent.http #439
Conversation
Rationale: I want to annotate one of these, so that we know the type of headers (which would allow us to detect the problem fixed by #415). if I write a stub for `IResponse` I'll have to write a stub for the entire `iweb` interface module, which seems like a PITA. Also: AFAICS `Response` is the only implementation of `IResponse`. So I feel a bit naughty, but not too naughty.
otherwise we can't call `abortConnection`.
I'm alarmed that this passes locally but doesn't in CI. Let's see if this works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, that seems like a decent stab at some murky stuff.
I'm wondering what the reason was for changing IResponse
to Response
? I guess you must have had your reasons, but I don't see them immediately.
# I don't like importing from _sslverify, but IOpenSSLTrustRoot isn't re-exported | ||
# anywhere else in twisted. | ||
from twisted.internet._sslverify import IOpenSSLTrustRoot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should use if TYPE_CHECKING:
for this since it's private?
edit: never mind, this is a stub, that's OK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also use this directly in sydent, see
sydent/sydent/http/httpcommon.py
Line 87 in 356beaf
return twisted.internet._sslverify.OpenSSLCertificateAuthorities( # type: ignore |
I don't think OpenSSLCertificateAuthorities is exported in twisted.internet.ssl
. /shrug
I felt dirty doing it, but it was a compromise to avoid stubbing the entire world. See the commit message for 793bc15. |
thanks! |
Many thanks for reviewing @reivilibre ! |
I tried to use `Response` rather than `IResponse` to avoid having to write a stub for the latter. There were other complications down the line from this. It was easier to change my mind, use `stubgen` and polish up the `iweb` stub. See also #439 (comment)
I tried to use `Response` rather than `IResponse` to avoid having to write a stub for the latter. There were other complications down the line from this. It was easier to change my mind, use `stubgen` and polish up the `iweb` stub. See also #439 (comment)
This one was a bit of a nightmare. Lots of interaction with twisted and quite a few false starts.
I've tried to chop this up into manageable commits to make this reviewable.