Skip to content

Commit fff4381

Browse files
committed
Expose execnet.Gateway and execnet.Channel for typing purposes
These two types prominently appear in the public API so let's allow to refer to them. The constructors are considered private.
1 parent db2f88e commit fff4381

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

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.
17+
* Re-exported ``Gateway`` and ``Channel`` from ``execnet``. The constructors
18+
are private.
1719
* Fixed ``GatewayBase.join()`` timeout argument getting ignored.
1820
* Removed support for Python 3.7.
1921
* Added official support for Python 3.12.

src/execnet/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"""
99

1010
from ._version import version as __version__
11+
from .gateway import Gateway
12+
from .gateway_base import Channel
1113
from .gateway_base import DataFormatError
1214
from .gateway_base import RemoteError
1315
from .gateway_base import TimeoutError
@@ -32,10 +34,12 @@
3234
"RemoteError",
3335
"TimeoutError",
3436
"XSpec",
37+
"Gateway",
3538
"Group",
3639
"MultiChannel",
3740
"RSync",
3841
"default_group",
42+
"Channel",
3943
"dumps",
4044
"loads",
4145
"load",

src/execnet/gateway.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Gateway(gateway_base.BaseGateway):
2727
_group: Group
2828

2929
def __init__(self, io: IO, spec: XSpec) -> None:
30+
""":private:"""
3031
super().__init__(io=io, id=spec.id, _startcount=1)
3132
self.spec = spec
3233
self._initreceive()

src/execnet/gateway_base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ class Channel:
708708
_executing = False
709709

710710
def __init__(self, gateway: BaseGateway, id: int) -> None:
711+
""":private:"""
711712
assert isinstance(id, int)
712713
assert not isinstance(gateway, type)
713714
self.gateway = gateway

src/execnet/gateway_bootstrap.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import execnet
99

1010
from . import gateway_base
11-
from .gateway import Gateway
1211
from .gateway_base import IO
1312
from .xspec import XSpec
1413

@@ -81,7 +80,7 @@ def sendexec(io: IO, *sources: str) -> None:
8180
io.write((repr(source) + "\n").encode("utf-8"))
8281

8382

84-
def bootstrap(io: IO, spec: XSpec) -> Gateway:
83+
def bootstrap(io: IO, spec: XSpec) -> execnet.Gateway:
8584
if spec.popen:
8685
if spec.via or spec.python:
8786
bootstrap_exec(io, spec)
@@ -93,5 +92,5 @@ def bootstrap(io: IO, spec: XSpec) -> Gateway:
9392
bootstrap_socket(io, spec)
9493
else:
9594
raise ValueError("unknown gateway type, can't bootstrap")
96-
gw = Gateway(io, spec)
95+
gw = execnet.Gateway(io, spec)
9796
return gw

0 commit comments

Comments
 (0)