Skip to content

Commit 42aeb82

Browse files
authored
Merge pull request #263 from bluetech/typing-fixes
Couple of typing fixes
2 parents 4d75439 + 5035913 commit 42aeb82

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
Also fixed ``init_popen_io`` to use ``closefd=False`` for shared stdin and stdout file
1616
descriptors, preventing ``Bad file descriptor`` errors triggered by test_stdouterrin_setnull.
1717
* The library is now typed and the typing is exposed to type-checkers.
18-
* Re-exported ``Gateway`` and ``Channel`` from ``execnet``. The constructors
19-
are private.
18+
* Re-exported ``Gateway``, ``Channel``, ``DumpError`` and ``LoadError`` from
19+
``execnet``. The constructors are private.
2020
* Fixed ``GatewayBase.join()`` timeout argument getting ignored.
2121
* Removed support for Python 3.7.
2222
* Added official support for Python 3.12.

src/execnet/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
from .gateway import Gateway
1212
from .gateway_base import Channel
1313
from .gateway_base import DataFormatError
14+
from .gateway_base import DumpError
15+
from .gateway_base import LoadError
1416
from .gateway_base import RemoteError
1517
from .gateway_base import TimeoutError
1618
from .gateway_base import dump
@@ -41,8 +43,10 @@
4143
"default_group",
4244
"Channel",
4345
"dumps",
46+
"dump",
47+
"DumpError",
4448
"loads",
4549
"load",
46-
"dump",
50+
"LoadError",
4751
"DataFormatError",
4852
]

src/execnet/gateway_base.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ def send(self, item: object) -> None:
911911
raise OSError(f"cannot send to {self!r}")
912912
self.gateway._send(Message.CHANNEL_DATA, self.id, dumps_internal(item))
913913

914-
def receive(self, timeout: float | None = None) -> object:
914+
def receive(self, timeout: float | None = None) -> Any:
915915
"""Receive a data item that was sent from the other side.
916916
917917
timeout: None [default] blocked waiting. A positive number
@@ -935,10 +935,10 @@ def receive(self, timeout: float | None = None) -> object:
935935
else:
936936
return x
937937

938-
def __iter__(self) -> Iterator[object]:
938+
def __iter__(self) -> Iterator[Any]:
939939
return self
940940

941-
def next(self) -> object:
941+
def next(self) -> Any:
942942
try:
943943
return self.receive()
944944
except EOFError:
@@ -1403,7 +1403,7 @@ def __init__(
14031403
else:
14041404
self.channelfactory = gw._channelfactory
14051405

1406-
def load(self, versioned: bool = False) -> object:
1406+
def load(self, versioned: bool = False) -> Any:
14071407
if versioned:
14081408
ver = self.stream.read(1)
14091409
if ver != DUMPFORMAT_VERSION:
@@ -1587,7 +1587,7 @@ def dump(byteio, obj: object) -> None:
15871587

15881588
def loads(
15891589
bytestring: bytes, py2str_as_py3str: bool = False, py3str_as_py2str: bool = False
1590-
) -> object:
1590+
) -> Any:
15911591
"""Deserialize the given bytestring to an object.
15921592
15931593
py2str_as_py3str: If true then string (str) objects previously
@@ -1609,7 +1609,7 @@ def loads(
16091609

16101610
def load(
16111611
io: ReadIO, py2str_as_py3str: bool = False, py3str_as_py2str: bool = False
1612-
) -> object:
1612+
) -> Any:
16131613
"""Derserialize an object form the specified stream.
16141614
16151615
Behaviour and parameters are otherwise the same as with ``loads``
@@ -1622,7 +1622,7 @@ def loads_internal(
16221622
bytestring: bytes,
16231623
channelfactory=None,
16241624
strconfig: tuple[bool, bool] | None = None,
1625-
) -> object:
1625+
) -> Any:
16261626
io = BytesIO(bytestring)
16271627
return Unserializer(io, channelfactory, strconfig).load()
16281628

src/execnet/multi.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from functools import partial
1212
from threading import Lock
1313
from typing import TYPE_CHECKING
14+
from typing import Any
1415
from typing import Callable
1516
from typing import Iterable
1617
from typing import Iterator
@@ -277,16 +278,16 @@ def send_each(self, item: object) -> None:
277278
ch.send(item)
278279

279280
@overload
280-
def receive_each(self, withchannel: Literal[False] = ...) -> list[object]:
281+
def receive_each(self, withchannel: Literal[False] = ...) -> list[Any]:
281282
pass
282283

283284
@overload
284-
def receive_each(self, withchannel: Literal[True]) -> list[tuple[Channel, object]]:
285+
def receive_each(self, withchannel: Literal[True]) -> list[tuple[Channel, Any]]:
285286
pass
286287

287288
def receive_each(
288289
self, withchannel: bool = False
289-
) -> list[tuple[Channel, object]] | list[object]:
290+
) -> list[tuple[Channel, Any]] | list[Any]:
290291
assert not hasattr(self, "_queue")
291292
l: list[object] = []
292293
for ch in self._channels:

0 commit comments

Comments
 (0)