mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Bump pyright version (#2871)
and fix all reported issues. We aren't sticking to the latest version this time because it has [a bug](https://github.com/microsoft/pyright/issues/5968).
This commit is contained in:
@@ -173,7 +173,7 @@ jobs:
|
|||||||
|
|
||||||
- uses: jakebailey/pyright-action@v1
|
- uses: jakebailey/pyright-action@v1
|
||||||
with:
|
with:
|
||||||
version: 1.1.320
|
version: 1.1.326
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ class Etcd3Client(AbstractEtcdClientWithFailover):
|
|||||||
|
|
||||||
def __init__(self, config: Dict[str, Any], dns_resolver: DnsCachingResolver, cache_ttl: int = 300) -> None:
|
def __init__(self, config: Dict[str, Any], dns_resolver: DnsCachingResolver, cache_ttl: int = 300) -> None:
|
||||||
self._token = None
|
self._token = None
|
||||||
self._cluster_version: Tuple[int] = tuple()
|
self._cluster_version: Tuple[int, ...] = tuple()
|
||||||
super(Etcd3Client, self).__init__({**config, 'version_prefix': '/v3beta'}, dns_resolver, cache_ttl)
|
super(Etcd3Client, self).__init__({**config, 'version_prefix': '/v3beta'}, dns_resolver, cache_ttl)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -836,7 +836,7 @@ class Kubernetes(AbstractDCS):
|
|||||||
self._api.configure_timeouts(self.loop_wait, self._retry.deadline, self.ttl)
|
self._api.configure_timeouts(self.loop_wait, self._retry.deadline, self.ttl)
|
||||||
|
|
||||||
# retriable_http_codes supposed to be either int, list of integers or comma-separated string with integers.
|
# retriable_http_codes supposed to be either int, list of integers or comma-separated string with integers.
|
||||||
retriable_http_codes = config.get('retriable_http_codes', [])
|
retriable_http_codes: Union[str, List[Union[str, int]]] = config.get('retriable_http_codes', [])
|
||||||
if not isinstance(retriable_http_codes, list):
|
if not isinstance(retriable_http_codes, list):
|
||||||
retriable_http_codes = [c.strip() for c in str(retriable_http_codes).split(',')]
|
retriable_http_codes = [c.strip() for c in str(retriable_http_codes).split(',')]
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class ZooKeeper(AbstractDCS):
|
|||||||
def __init__(self, config: Dict[str, Any]) -> None:
|
def __init__(self, config: Dict[str, Any]) -> None:
|
||||||
super(ZooKeeper, self).__init__(config)
|
super(ZooKeeper, self).__init__(config)
|
||||||
|
|
||||||
hosts = config.get('hosts', [])
|
hosts: Union[str, List[str]] = config.get('hosts', [])
|
||||||
if isinstance(hosts, list):
|
if isinstance(hosts, list):
|
||||||
hosts = ','.join(hosts)
|
hosts = ','.join(hosts)
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -772,13 +772,13 @@ class Ha(object):
|
|||||||
if cluster_history:
|
if cluster_history:
|
||||||
self.dcs.set_history_value('[]')
|
self.dcs.set_history_value('[]')
|
||||||
elif not cluster_history or cluster_history[-1][0] != primary_timeline - 1 or len(cluster_history[-1]) != 5:
|
elif not cluster_history or cluster_history[-1][0] != primary_timeline - 1 or len(cluster_history[-1]) != 5:
|
||||||
cluster_history = {line[0]: line for line in cluster_history}
|
cluster_history_dict: Dict[int, List[Any]] = {line[0]: list(line) for line in cluster_history}
|
||||||
history: List[List[Any]] = list(map(list, self.state_handler.get_history(primary_timeline)))
|
history: List[List[Any]] = list(map(list, self.state_handler.get_history(primary_timeline)))
|
||||||
if self.cluster.config:
|
if self.cluster.config:
|
||||||
history = history[-self.cluster.config.max_timelines_history:]
|
history = history[-self.cluster.config.max_timelines_history:]
|
||||||
for line in history:
|
for line in history:
|
||||||
# enrich current history with promotion timestamps stored in DCS
|
# enrich current history with promotion timestamps stored in DCS
|
||||||
cluster_history_line = list(cluster_history.get(line[0], []))
|
cluster_history_line = cluster_history_dict.get(line[0], [])
|
||||||
if len(line) == 3 and len(cluster_history_line) >= 4 and cluster_history_line[1] == line[1]:
|
if len(line) == 3 and len(cluster_history_line) >= 4 and cluster_history_line[1] == line[1]:
|
||||||
line.append(cluster_history_line[3])
|
line.append(cluster_history_line[3])
|
||||||
if len(cluster_history_line) == 5:
|
if len(cluster_history_line) == 5:
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ class Postgresql(object):
|
|||||||
r'lsn: ([0-9A-Fa-f]+/[0-9A-Fa-f]+), prev ([0-9A-Fa-f]+/[0-9A-Fa-f]+), '
|
r'lsn: ([0-9A-Fa-f]+/[0-9A-Fa-f]+), prev ([0-9A-Fa-f]+/[0-9A-Fa-f]+), '
|
||||||
r'.*?desc: (.+)', out.decode('utf-8'))
|
r'.*?desc: (.+)', out.decode('utf-8'))
|
||||||
if match:
|
if match:
|
||||||
return match.groups()
|
return match.group(1), match.group(2), match.group(3), match.group(4)
|
||||||
return None, None, None, None
|
return None, None, None, None
|
||||||
|
|
||||||
def latest_checkpoint_location(self) -> Optional[int]:
|
def latest_checkpoint_location(self) -> Optional[int]:
|
||||||
@@ -1023,7 +1023,7 @@ class Postgresql(object):
|
|||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def get_replication_connection_cursor(self, host: Optional[str] = None, port: int = 5432,
|
def get_replication_connection_cursor(self, host: Optional[str] = None, port: Union[int, str] = 5432,
|
||||||
**kwargs: Any) -> Iterator[Union['cursor', 'Cursor[Any]']]:
|
**kwargs: Any) -> Iterator[Union['cursor', 'Cursor[Any]']]:
|
||||||
conn_kwargs = self.config.replication.copy()
|
conn_kwargs = self.config.replication.copy()
|
||||||
conn_kwargs.update(host=host, port=int(port) if port else None, user=conn_kwargs.pop('username'),
|
conn_kwargs.update(host=host, port=int(port) if port else None, user=conn_kwargs.pop('username'),
|
||||||
|
|||||||
@@ -1026,17 +1026,14 @@ class ConfigHandler(object):
|
|||||||
# "notify" connection_pool about the "new" local connection address
|
# "notify" connection_pool about the "new" local connection address
|
||||||
self._postgresql.connection_pool.conn_kwargs = local_conn_kwargs
|
self._postgresql.connection_pool.conn_kwargs = local_conn_kwargs
|
||||||
|
|
||||||
def _get_pg_settings(
|
def _get_pg_settings(self, names: Collection[str]) -> Dict[Any, Tuple[Any, ...]]:
|
||||||
self, names: Collection[str]
|
|
||||||
) -> Dict[str, Tuple[str, str, Optional[str], str, str, Optional[str]]]:
|
|
||||||
return {r[0]: r for r in self._postgresql.query(('SELECT name, setting, unit, vartype, context, sourcefile'
|
return {r[0]: r for r in self._postgresql.query(('SELECT name, setting, unit, vartype, context, sourcefile'
|
||||||
+ ' FROM pg_catalog.pg_settings '
|
+ ' FROM pg_catalog.pg_settings '
|
||||||
+ ' WHERE pg_catalog.lower(name) = ANY(%s)'),
|
+ ' WHERE pg_catalog.lower(name) = ANY(%s)'),
|
||||||
[n.lower() for n in names])}
|
[n.lower() for n in names])}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _handle_wal_buffers(old_values: Dict[str, Tuple[str, str, Optional[str], str, str, Optional[str]]],
|
def _handle_wal_buffers(old_values: Dict[Any, Tuple[Any, ...]], changes: CaseInsensitiveDict) -> None:
|
||||||
changes: CaseInsensitiveDict) -> None:
|
|
||||||
wal_block_size = parse_int(old_values['wal_block_size'][1]) or 8192
|
wal_block_size = parse_int(old_values['wal_block_size'][1]) or 8192
|
||||||
wal_segment_size = old_values['wal_segment_size']
|
wal_segment_size = old_values['wal_segment_size']
|
||||||
wal_segment_unit = parse_int(wal_segment_size[2], 'B') or 8192 \
|
wal_segment_unit = parse_int(wal_segment_size[2], 'B') or 8192 \
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ class SlotsHandler:
|
|||||||
' true AS dropped FROM slots WHERE not active) '
|
' true AS dropped FROM slots WHERE not active) '
|
||||||
'SELECT active, COALESCE(dropped, false) FROM slots'
|
'SELECT active, COALESCE(dropped, false) FROM slots'
|
||||||
' FULL OUTER JOIN dropped ON true'), name)
|
' FULL OUTER JOIN dropped ON true'), name)
|
||||||
return rows[0] if rows else (False, False)
|
return (rows[0][0], rows[0][1]) if rows else (False, False)
|
||||||
|
|
||||||
def _drop_incorrect_slots(self, cluster: Cluster, slots: Dict[str, Any], paused: bool) -> None:
|
def _drop_incorrect_slots(self, cluster: Cluster, slots: Dict[str, Any], paused: bool) -> None:
|
||||||
"""Compare required slots and configured as permanent slots with those found, dropping extraneous ones.
|
"""Compare required slots and configured as permanent slots with those found, dropping extraneous ones.
|
||||||
|
|||||||
Reference in New Issue
Block a user