diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index bc6a1be3..8b73c6e7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -173,7 +173,7 @@ jobs: - uses: jakebailey/pyright-action@v1 with: - version: 1.1.320 + version: 1.1.326 docs: runs-on: ubuntu-latest diff --git a/patroni/dcs/etcd3.py b/patroni/dcs/etcd3.py index 0a71caa0..5cbd813f 100644 --- a/patroni/dcs/etcd3.py +++ b/patroni/dcs/etcd3.py @@ -205,7 +205,7 @@ class Etcd3Client(AbstractEtcdClientWithFailover): def __init__(self, config: Dict[str, Any], dns_resolver: DnsCachingResolver, cache_ttl: int = 300) -> 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) try: diff --git a/patroni/dcs/kubernetes.py b/patroni/dcs/kubernetes.py index 3be7cee3..d4158368 100644 --- a/patroni/dcs/kubernetes.py +++ b/patroni/dcs/kubernetes.py @@ -836,7 +836,7 @@ class Kubernetes(AbstractDCS): 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 = 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): retriable_http_codes = [c.strip() for c in str(retriable_http_codes).split(',')] diff --git a/patroni/dcs/zookeeper.py b/patroni/dcs/zookeeper.py index e4af1b1f..e3cc1d69 100644 --- a/patroni/dcs/zookeeper.py +++ b/patroni/dcs/zookeeper.py @@ -90,7 +90,7 @@ class ZooKeeper(AbstractDCS): def __init__(self, config: Dict[str, Any]) -> None: super(ZooKeeper, self).__init__(config) - hosts = config.get('hosts', []) + hosts: Union[str, List[str]] = config.get('hosts', []) if isinstance(hosts, list): hosts = ','.join(hosts) diff --git a/patroni/ha.py b/patroni/ha.py index a8274ee3..d5d6e16b 100644 --- a/patroni/ha.py +++ b/patroni/ha.py @@ -772,13 +772,13 @@ class Ha(object): if cluster_history: self.dcs.set_history_value('[]') 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))) if self.cluster.config: history = history[-self.cluster.config.max_timelines_history:] for line in history: # 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]: line.append(cluster_history_line[3]) if len(cluster_history_line) == 5: diff --git a/patroni/postgresql/__init__.py b/patroni/postgresql/__init__.py index a37e15e1..9bd53dac 100644 --- a/patroni/postgresql/__init__.py +++ b/patroni/postgresql/__init__.py @@ -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'.*?desc: (.+)', out.decode('utf-8')) if match: - return match.groups() + return match.group(1), match.group(2), match.group(3), match.group(4) return None, None, None, None def latest_checkpoint_location(self) -> Optional[int]: @@ -1023,7 +1023,7 @@ class Postgresql(object): return None, None @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]']]: conn_kwargs = self.config.replication.copy() conn_kwargs.update(host=host, port=int(port) if port else None, user=conn_kwargs.pop('username'), diff --git a/patroni/postgresql/config.py b/patroni/postgresql/config.py index 315bf8c7..a918a2cf 100644 --- a/patroni/postgresql/config.py +++ b/patroni/postgresql/config.py @@ -1026,17 +1026,14 @@ class ConfigHandler(object): # "notify" connection_pool about the "new" local connection address self._postgresql.connection_pool.conn_kwargs = local_conn_kwargs - def _get_pg_settings( - self, names: Collection[str] - ) -> Dict[str, Tuple[str, str, Optional[str], str, str, Optional[str]]]: + def _get_pg_settings(self, names: Collection[str]) -> Dict[Any, Tuple[Any, ...]]: return {r[0]: r for r in self._postgresql.query(('SELECT name, setting, unit, vartype, context, sourcefile' + ' FROM pg_catalog.pg_settings ' + ' WHERE pg_catalog.lower(name) = ANY(%s)'), [n.lower() for n in names])} @staticmethod - def _handle_wal_buffers(old_values: Dict[str, Tuple[str, str, Optional[str], str, str, Optional[str]]], - changes: CaseInsensitiveDict) -> None: + def _handle_wal_buffers(old_values: Dict[Any, Tuple[Any, ...]], changes: CaseInsensitiveDict) -> None: wal_block_size = parse_int(old_values['wal_block_size'][1]) or 8192 wal_segment_size = old_values['wal_segment_size'] wal_segment_unit = parse_int(wal_segment_size[2], 'B') or 8192 \ diff --git a/patroni/postgresql/slots.py b/patroni/postgresql/slots.py index 7391f543..f6090a3b 100644 --- a/patroni/postgresql/slots.py +++ b/patroni/postgresql/slots.py @@ -313,7 +313,7 @@ class SlotsHandler: ' true AS dropped FROM slots WHERE not active) ' 'SELECT active, COALESCE(dropped, false) FROM slots' ' 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: """Compare required slots and configured as permanent slots with those found, dropping extraneous ones.