diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 0540cca0..8b73c6e7 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -173,4 +173,28 @@ jobs: - uses: jakebailey/pyright-action@v1 with: - version: 1.1.320 + version: 1.1.326 + + docs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Set up Python 3.11 + uses: actions/setup-python@v4 + with: + python-version: 3.11 + cache: pip + + - name: Install dependencies + run: pip install tox + + - name: Install package dependencies + run: | + sudo apt update \ + && sudo apt install -y \ + latexmk texlive-latex-extra tex-gyre \ + --no-install-recommends + + - name: Generate documentation + run: tox -m docs diff --git a/patroni/dcs/etcd3.py b/patroni/dcs/etcd3.py index e5e069c5..74a9014c 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 ce1c1a44..d2a340d8 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 ed2b71ed..def00521 100644 --- a/patroni/dcs/zookeeper.py +++ b/patroni/dcs/zookeeper.py @@ -89,7 +89,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 e72768f8..b7479182 100644 --- a/patroni/ha.py +++ b/patroni/ha.py @@ -728,13 +728,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 2caff6d3..a0a7dd1e 100644 --- a/patroni/postgresql/__init__.py +++ b/patroni/postgresql/__init__.py @@ -550,7 +550,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]: @@ -1006,7 +1006,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 7e3d39b8..80f5be38 100644 --- a/patroni/postgresql/config.py +++ b/patroni/postgresql/config.py @@ -1005,17 +1005,14 @@ class ConfigHandler(object): self._postgresql.connection_string = uri('postgres', netloc, self._postgresql.database) self._postgresql.set_connection_kwargs(self.local_connect_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 2ead1a27..114480d0 100644 --- a/patroni/postgresql/slots.py +++ b/patroni/postgresql/slots.py @@ -215,7 +215,7 @@ class SlotsHandler(object): row = cursor.fetchone() if not row: row = (False, False) - return row + return row[0], row[1] def _drop_incorrect_slots(self, cluster: Cluster, slots: Dict[str, Any], paused: bool) -> None: # drop old replication slots which are not presented in desired slots