]> git.openstreetmap.org Git - nominatim.git/commitdiff
mypy: fix new warnings due to external type updates
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 5 Sep 2022 15:38:48 +0000 (17:38 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 5 Sep 2022 15:39:35 +0000 (17:39 +0200)
nominatim/db/async_connection.py
nominatim/db/connection.py
nominatim/tools/check_database.py

index a2c8fe4de8a630e54001b7a08e0da41c79a9684d..d1e542f572472ec60a6abd3be276d2094ed1458f 100644 (file)
@@ -94,7 +94,8 @@ class DBConnection:
 
         # Use a dict to hand in the parameters because async is a reserved
         # word in Python3.
-        self.conn = psycopg2.connect(**{'dsn': self.dsn, 'async': True})
+        self.conn = psycopg2.connect(**{'dsn': self.dsn, 'async': True}) # type: ignore
+        assert self.conn
         self.wait()
 
         if cursor_factory is not None:
index 44a293d43b7f58dbfd19690525989b69333a9486..77d463d81d8e4dc0522bf1b2702aff0db66f21df 100644 (file)
@@ -189,7 +189,7 @@ def connect(dsn: str) -> ConnectionContext:
     try:
         conn = psycopg2.connect(dsn, connection_factory=Connection)
         ctxmgr = cast(ConnectionContext, contextlib.closing(conn))
-        ctxmgr.connection = cast(Connection, conn)
+        ctxmgr.connection = conn
         return ctxmgr
     except psycopg2.OperationalError as err:
         raise UsageError(f"Cannot connect to database: {err}") from err
index 7372a49fd215564623c9c47bd3df83001f6edfe8..80358f200edda55e51cc14fcb2ba6d4825b1a27e 100644 (file)
@@ -268,7 +268,7 @@ def check_database_index_valid(conn: Connection, _: Configuration) -> CheckResul
                         WHERE pg_index.indisvalid = false
                         AND pg_index.indexrelid = pg_class.oid""")
 
-        broken = list(cur)
+        broken = [c[0] for c in cur]
 
     if broken:
         return CheckState.FAIL, dict(indexes='\n  '.join(broken))