Autobahn WebSocket Protocol - Improve typing#1838
Autobahn WebSocket Protocol - Improve typing#1838oberstet merged 3 commits intocrossbario:masterfrom
Conversation
| --ignore call-non-callable \ | ||
| --ignore invalid-assignment \ | ||
| --ignore invalid-argument-type \ | ||
| --ignore invalid-return-type \ |
There was a problem hiding this comment.
With the changes in autobahn/wamp, this check now passes
| --ignore too-many-positional-arguments \ | ||
| --ignore unknown-argument \ | ||
| --ignore non-subscriptable \ | ||
| --ignore not-subscriptable \ |
There was a problem hiding this comment.
Minor typo to get the CI to pass
|
thanks a lot for contributing! in fact, this is funny/surprising, since adding/improving type hints is something I became interested in myself just recently, coming from a different angle (SLSA L4 / WASM). this broader context and resulting "style guide" as related to type hints is now documented in #1839 I've added specific references to your PR, and I'd be very curious about your comments, remarks and general feedback! please don't get this wrong, I am not asking for "full type hints everywhere" for this PR. the GitHub issue is just for giving the "outer scope / aggregate issue" as an anchor - eg I noticed you did add an audit file to this PR already (very good, thanks a lot!), but that does not yet refer a GitHub issue - because there wasn't one (which is important for the audit file as this properly relates "issue to PR to CI/CD to merge-to-master" and allows developers and users to figure out how these related also retrospectively) |
|
Great minds think alike @oberstet! I've pushed a new commit with some improvements, as pointed out in the guide:
Missing:
There are still a ton of types missing, even in this small subsection - and I'm not familiar enough with the codebase/functionality to determine the correct types for them. That's why I left some as-is. General remarks / feedbackAs someone who went through the same process of 'cleaning' a codebase both in terms of style and typehints, I have some advice, if I can:
Speaking of: running |
|
Thanks so much @bblommers — merging this now! 🎉 Really appreciated how quickly you aligned with the style guide after I filed #1839. The On your feedback:
Remaining typing work (untyped payload params, more modules) is now tracked in #1839 — no pressure, but if you're interested in picking up more files, you'd be very welcome to. The high-priority ones are Thanks again for the contribution and the thoughtful process feedback! |
Description
Adds typehints to
autobahn/twisted/websocket.pyandautobahn/websocket/protocol. I realize that's only a small section of the codebase, those just contain the classes that I use the most 🙂Some style choices that I made:
X | Ynotation (instead of theOptional[X]that is used as well in this codebase)dict[..]andtuple[..], as that is the preferred way for Python >= 3.10 (instead oftyping.Dict[..]andtyping.Tuple[..]):style..from the docstrings, if the type is now available as a typehint, just because it seems superfluous to specify the type twiceChecklist
the style guidelines of this project
is effective or that my feature works
updated the changelog
in this PR