Typing fixes and improvements for Socket, Frame, and Context#2184
Open
jorenham wants to merge 3 commits into
Open
Typing fixes and improvements for Socket, Frame, and Context#2184jorenham wants to merge 3 commits into
Socket, Frame, and Context#2184jorenham wants to merge 3 commits into
Conversation
jorenham
marked this pull request as draft
May 19, 2026 16:48
Contributor
Author
|
Hmm apparently I messed up somewhere... Marking this as draft until I fixed it |
Contributor
Author
|
Well, as it turns out, these new mypy errors uncovered actual bugs in the examples. For example: $ python examples/poll/reqrep.py
Running polling tests for REQ/REP sockets...
Traceback (most recent call last):
File "/home/joren/Workspace/pyzmq/examples/poll/reqrep.py", line 37, in <module>
s2.send('msg1')
~~~~~~~^^^^^^^^
File "/home/joren/Workspace/pyzmq/zmq/sugar/socket.py", line 713, in send
return super().send(data, flags=flags, copy=copy, track=track)
~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "zmq/backend/cython/_zmq.py", line 1152, in zmq.backend.cython._zmq.Socket.send
def send(self, data, flags=0, copy: bint = True, track: bint = False):
File "zmq/backend/cython/_zmq.py", line 1197, in zmq.backend.cython._zmq.Socket.send
raise TypeError("unicode not allowed, use send_string")
TypeError: unicode not allowed, use send_stringI'll fix the examples as well then. |
jorenham
force-pushed
the
typing/backend/coverage
branch
from
May 19, 2026 16:57
d95ca07 to
453c633
Compare
jorenham
marked this pull request as ready for review
May 19, 2026 17:03
This was referenced May 19, 2026
jorenham
force-pushed
the
typing/backend/coverage
branch
from
July 9, 2026 19:05
e566a08 to
53c7ee2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR was initially intended for filling in the missing public type annotations in
zmq.backend, like #2183 and #2182. But while doing so, I noticed several typing issues: incorrect return types, incompetible overrides, incorrect type variable variance, and some minor overload issues. Because, you see, mypy completely ignores unannotated functions by default. So by annotating these methods, several hidden typing issues surfaced. Those issues weren't as simple as fixing one thing; I had to fix a whole bunch of stuff to get everything nice and consistent.This unfortunately also caused this to not be as self-contained as I had hoped it would be. I don't think there's a good way to split this up though, or at least, not in a way that mypy will like.
FWIW: I had Claude Opus 4.7 review (but not touch) every change here. After iterating like this for a bit, it now seems to fully agree with the changes. But don't worry, those reviews is all I used AI for :)
Besides the typing fixes, this also increases type coverage by 4.07%.
Thanks for submitting a PR!
LLM/AI contributions are not accepted.
Please make sure: