From: Sarah Hoffmann Date: Sun, 17 Sep 2023 13:09:34 +0000 (+0200) Subject: 'fix' issues with recent changes to psycopg2 typing X-Git-Tag: v4.4.0~98^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/f029fb3c656788b44fa758e627592d27014528d5 'fix' issues with recent changes to psycopg2 typing Some of the changes just make the warnings go away. The typing info is still incorrect on the stub side, as far as I can determine. --- diff --git a/nominatim/db/async_connection.py b/nominatim/db/async_connection.py index d1e542f5..07767e48 100644 --- a/nominatim/db/async_connection.py +++ b/nominatim/db/async_connection.py @@ -69,8 +69,8 @@ class DBConnection: self.current_params: Optional[Sequence[Any]] = None self.ignore_sql_errors = ignore_sql_errors - self.conn: Optional['psycopg2.connection'] = None - self.cursor: Optional['psycopg2.cursor'] = None + self.conn: Optional['psycopg2._psycopg.connection'] = None + self.cursor: Optional['psycopg2._psycopg.cursor'] = None self.connect(cursor_factory=cursor_factory) def close(self) -> None: @@ -78,7 +78,7 @@ class DBConnection: """ if self.conn is not None: if self.cursor is not None: - self.cursor.close() # type: ignore[no-untyped-call] + self.cursor.close() self.cursor = None self.conn.close() diff --git a/nominatim/db/connection.py b/nominatim/db/connection.py index 77d463d8..a64cbfaf 100644 --- a/nominatim/db/connection.py +++ b/nominatim/db/connection.py @@ -31,7 +31,7 @@ class Cursor(psycopg2.extras.DictCursor): """ Query execution that logs the SQL query when debugging is enabled. """ if LOG.isEnabledFor(logging.DEBUG): - LOG.debug(self.mogrify(query, args).decode('utf-8')) # type: ignore[no-untyped-call] + LOG.debug(self.mogrify(query, args).decode('utf-8')) # type: ignore[arg-type] super().execute(query, args) diff --git a/nominatim/db/utils.py b/nominatim/db/utils.py index 9a7b4f16..d9154ed9 100644 --- a/nominatim/db/utils.py +++ b/nominatim/db/utils.py @@ -118,4 +118,4 @@ class CopyBuffer: """ if self.buffer.tell() > 0: self.buffer.seek(0) - cur.copy_from(self.buffer, table, columns=columns) # type: ignore[no-untyped-call] + cur.copy_from(self.buffer, table, columns=columns) # type: ignore[arg-type]