33from __future__ import annotations
44from 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
1414from psycopg2 import sql
1515# pylint can't seem to find the items in psycopg2 despite being available
1616from psycopg2 ._psycopg import cursor # pylint: disable=no-name-in-module
2424register_uuid ()
2525
2626
27- # Generic doesn't need a more descriptive name
28- # pylint: disable=invalid-name
29- T = TypeVar ('T' )
30-
3127Query = 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