3
3
from __future__ import annotations
4
4
from typing import (
5
5
Any ,
6
- TypeVar ,
7
- Union ,
8
- Optional ,
6
+ Dict ,
9
7
Hashable ,
10
8
List ,
11
- Dict )
9
+ Optional ,
10
+ Union ,
11
+ )
12
12
13
- from psycopg2 .extras import register_uuid
13
+ from psycopg2 .extras import register_uuid , RealDictRow
14
14
from psycopg2 import sql
15
15
# pylint can't seem to find the items in psycopg2 despite being available
16
16
from psycopg2 ._psycopg import cursor # pylint: disable=no-name-in-module
24
24
register_uuid ()
25
25
26
26
27
- # Generic doesn't need a more descriptive name
28
- # pylint: disable=invalid-name
29
- T = TypeVar ('T' )
30
-
31
27
Query = Union [str , sql .Composed ]
32
28
33
29
@@ -60,7 +56,7 @@ def _execute_query(
60
56
params : Optional [Dict [Hashable , Any ]] = None ,
61
57
) -> None :
62
58
if params :
63
- db_cursor .execute (query , params ) # type: ignore
59
+ db_cursor .execute (query , params )
64
60
else :
65
61
db_cursor .execute (query )
66
62
@@ -88,7 +84,7 @@ def execute_and_return(
88
84
self ,
89
85
query : Query ,
90
86
params : Optional [Dict [Hashable , Any ]] = None ,
91
- ) -> List [T ]:
87
+ ) -> List [RealDictRow ]:
92
88
"""Execute the given SQL query & return the result.
93
89
94
90
Arguments:
@@ -102,5 +98,5 @@ def execute_and_return(
102
98
with self ._connection .cursor () as db_cursor :
103
99
self ._execute_query (db_cursor , query , params )
104
100
105
- result : List [T ] = db_cursor .fetchall ()
101
+ result : List [RealDictRow ] = db_cursor .fetchall ()
106
102
return result
0 commit comments