Skip to content

Commit 26c6a1c

Browse files
PostgresNode is updated (typing) (#361)
1 parent 498e735 commit 26c6a1c

1 file changed

Lines changed: 23 additions & 10 deletions

File tree

src/node.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,14 @@ def get_control_data(self):
951951

952952
return out_dict
953953

954-
def slow_start(self, replica=False, dbname='template1', username=None, max_attempts=0, exec_env=None):
954+
def slow_start(
955+
self,
956+
replica: bool = False,
957+
dbname: typing.Optional[str] = 'template1',
958+
username: typing.Optional[str] = None,
959+
max_attempts: int = 0,
960+
exec_env: typing.Optional[typing.Dict[str, str]] = None,
961+
):
955962
"""
956963
Starts the PostgreSQL instance and then polls the instance
957964
until it reaches the expected state (primary or replica). The state is checked
@@ -964,6 +971,8 @@ def slow_start(self, replica=False, dbname='template1', username=None, max_attem
964971
If False, waits for the instance to be in primary mode. Default is False.
965972
max_attempts:
966973
"""
974+
assert dbname is None or type(dbname) is str
975+
assert username is None or type(username) is str
967976
assert exec_env is None or type(exec_env) is dict
968977

969978
self.start(exec_env=exec_env)
@@ -1608,15 +1617,17 @@ def restore(self, filename, dbname=None, username=None):
16081617
self.psql(filename=filename, dbname=dbname, username=username)
16091618

16101619
@method_decorator(positional_args_hack(['dbname', 'query']))
1611-
def poll_query_until(self,
1612-
query,
1613-
dbname=None,
1614-
username=None,
1615-
max_attempts=0,
1616-
sleep_time: typing.Union[int, float] = 1,
1617-
expected=True,
1618-
commit=True,
1619-
suppress=None):
1620+
def poll_query_until(
1621+
self,
1622+
query,
1623+
dbname: typing.Optional[str] = None,
1624+
username: typing.Optional[str] = None,
1625+
max_attempts: int = 0,
1626+
sleep_time: typing.Union[int, float] = 1,
1627+
expected: bool = True,
1628+
commit: bool = True,
1629+
suppress: typing.Optional[typing.Iterable[BaseException]] = None,
1630+
) -> None:
16201631
"""
16211632
Run a query once per second until it returns 'expected'.
16221633
Query should return a single value (1 row, 1 column).
@@ -1643,6 +1654,8 @@ def poll_query_until(self,
16431654
assert max_attempts >= 0
16441655
assert type(sleep_time) in [int, float]
16451656
assert sleep_time > 0
1657+
assert suppress is None or isinstance(suppress, typing.Iterable)
1658+
16461659
attempts = 0
16471660
while max_attempts == 0 or attempts < max_attempts:
16481661
try:

0 commit comments

Comments
 (0)