diff --git a/swh/provenance/postgresql/archive.py b/swh/provenance/postgresql/archive.py --- a/swh/provenance/postgresql/archive.py +++ b/swh/provenance/postgresql/archive.py @@ -3,7 +3,7 @@ # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -from typing import Any, Dict, Iterable, List, Tuple +from typing import Any, Dict, Iterable, List, Tuple, cast import psycopg2.extensions @@ -112,7 +112,7 @@ """, (revision_id,), ) - return cursor.fetchall() + return cast(List[Tuple[Sha1Git, Sha1Git]], cursor.fetchall()) @statsd.timed(metric=ARCHIVE_DURATION_METRIC, tags={"method": "snapshot_get_heads"}) def snapshot_get_heads(self, id: Sha1Git) -> Iterable[Sha1Git]: diff --git a/swh/provenance/postgresql/provenance.py b/swh/provenance/postgresql/provenance.py --- a/swh/provenance/postgresql/provenance.py +++ b/swh/provenance/postgresql/provenance.py @@ -90,7 +90,9 @@ if self._flavor is None: with self.transaction(readonly=True) as cursor: cursor.execute("SELECT swh_get_dbflavor() AS flavor") - self._flavor = cursor.fetchone()["flavor"] + flavor = cursor.fetchone() + assert flavor # please mypy + self._flavor = flavor["flavor"] assert self._flavor is not None return self._flavor