Skip to content

Commit 864b5ac

Browse files
Fix client query_and_return return type.
Client has no knowledge of what the return type is or should be. Fixed to return `RealDictRow` & removed the T TypeVar from sync_client.
1 parent 3ff178b commit 864b5ac

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

db_wrapper/client/sync_client.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
from __future__ import annotations
44
from typing import (
55
Any,
6-
TypeVar,
7-
Union,
8-
Optional,
6+
Dict,
97
Hashable,
108
List,
11-
Dict)
9+
Optional,
10+
Union,
11+
)
1212

13-
from psycopg2.extras import register_uuid
13+
from psycopg2.extras import register_uuid, RealDictRow
1414
from psycopg2 import sql
1515
# pylint can't seem to find the items in psycopg2 despite being available
1616
from psycopg2._psycopg import cursor # pylint: disable=no-name-in-module
@@ -24,10 +24,6 @@
2424
register_uuid()
2525

2626

27-
# Generic doesn't need a more descriptive name
28-
# pylint: disable=invalid-name
29-
T = TypeVar('T')
30-
3127
Query = Union[str, sql.Composed]
3228

3329

@@ -60,7 +56,7 @@ def _execute_query(
6056
params: Optional[Dict[Hashable, Any]] = None,
6157
) -> None:
6258
if params:
63-
db_cursor.execute(query, params) # type: ignore
59+
db_cursor.execute(query, params)
6460
else:
6561
db_cursor.execute(query)
6662

@@ -88,7 +84,7 @@ def execute_and_return(
8884
self,
8985
query: Query,
9086
params: Optional[Dict[Hashable, Any]] = None,
91-
) -> List[T]:
87+
) -> List[RealDictRow]:
9288
"""Execute the given SQL query & return the result.
9389
9490
Arguments:
@@ -102,5 +98,5 @@ def execute_and_return(
10298
with self._connection.cursor() as db_cursor:
10399
self._execute_query(db_cursor, query, params)
104100

105-
result: List[T] = db_cursor.fetchall()
101+
result: List[RealDictRow] = db_cursor.fetchall()
106102
return result

0 commit comments

Comments
 (0)