Skip to content

Commit

Permalink
'fix' issues with recent changes to psycopg2 typing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lonvia committed Sep 17, 2023
1 parent 44da684 commit f029fb3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions nominatim/db/async_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ def __init__(self, dsn: str,
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:
""" Close all open connections. Does not wait for pending requests.
"""
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()

Expand Down
2 changes: 1 addition & 1 deletion nominatim/db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def execute(self, query: Query, args: Any = None) -> None:
""" 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)

Expand Down
2 changes: 1 addition & 1 deletion nominatim/db/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ def copy_out(self, cur: Cursor, table: str, columns: Optional[Iterable[str]] = N
"""
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]

0 comments on commit f029fb3

Please sign in to comment.