Skip to content

Commit 6b5e728

Browse files
committed
add type alias for recv_json
slightly narrows return type
1 parent dde5d91 commit 6b5e728

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

zmq/sugar/socket.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141

4242
_SocketType = TypeVar("_SocketType", bound="Socket")
4343

44+
_JSONType: TypeAlias = "int | str | bool | list[_JSONType] | dict[str, _JSONType]"
45+
4446

4547
class _SocketContext(Generic[_SocketType]):
4648
"""Context Manager for socket bind/unbind"""
@@ -1018,7 +1020,7 @@ def send_json(self, obj: Any, flags: int = 0, **kwargs) -> None:
10181020
msg = jsonapi.dumps(obj, **kwargs)
10191021
return self.send(msg, flags=flags, **send_kwargs)
10201022

1021-
def recv_json(self, flags: int = 0, **kwargs) -> list | str | int | float | dict:
1023+
def recv_json(self, flags: int = 0, **kwargs) -> _JSONType:
10221024
"""Receive a Python object as a message using json to serialize.
10231025
10241026
Keyword arguments are passed on to json.loads

0 commit comments

Comments
 (0)