Skip to content

Commit 8fb947e

Browse files
ProcessProxy is updated (RO, typing, asserts) (#304)
1 parent faee1df commit 8fb947e

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

src/node.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,20 @@ class ProcessProxy(object):
119119
ptype: instance of ProcessType
120120
"""
121121

122-
def __init__(self, process, ptype=None):
123-
self.process = process
124-
self.ptype = ptype or ProcessType.from_process(process)
122+
_process: any
123+
_ptype: ProcessType
124+
125+
def __init__(self, process, ptype: typing.Optional[ProcessType] = None):
126+
assert process is not None
127+
assert ptype is None or type(ptype) == ProcessType # noqa: E721
128+
self._process = process
129+
130+
if ptype is not None:
131+
self._ptype = ptype
132+
else:
133+
self._ptype = ProcessType.from_process(process)
134+
assert type(self._ptype) == ProcessType # noqa: E721
135+
return
125136

126137
def __getattr__(self, name):
127138
return getattr(self.process, name)
@@ -132,6 +143,16 @@ def __repr__(self):
132143
str(self.ptype),
133144
repr(self.process))
134145

146+
@property
147+
def process(self) -> any:
148+
assert self._process is not None
149+
return self._process
150+
151+
@property
152+
def ptype(self) -> ProcessType:
153+
assert type(self._ptype) == ProcessType # noqa: E721
154+
return self._ptype
155+
135156

136157
class PostgresNode(object):
137158
# a max number of node start attempts

0 commit comments

Comments
 (0)