mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 12:16:09 -04:00
Update type hints for Cursor to match PEP 249. (#9299)
This commit is contained in:
parent
5a9cdaa6e9
commit
d882fbca38
5 changed files with 48 additions and 18 deletions
|
@ -158,8 +158,8 @@ class LoggingDatabaseConnection:
|
|||
def commit(self) -> None:
|
||||
self.conn.commit()
|
||||
|
||||
def rollback(self, *args, **kwargs) -> None:
|
||||
self.conn.rollback(*args, **kwargs)
|
||||
def rollback(self) -> None:
|
||||
self.conn.rollback()
|
||||
|
||||
def __enter__(self) -> "Connection":
|
||||
self.conn.__enter__()
|
||||
|
@ -244,12 +244,15 @@ class LoggingTransaction:
|
|||
assert self.exception_callbacks is not None
|
||||
self.exception_callbacks.append((callback, args, kwargs))
|
||||
|
||||
def fetchone(self) -> Optional[Tuple]:
|
||||
return self.txn.fetchone()
|
||||
|
||||
def fetchmany(self, size: Optional[int] = None) -> List[Tuple]:
|
||||
return self.txn.fetchmany(size=size)
|
||||
|
||||
def fetchall(self) -> List[Tuple]:
|
||||
return self.txn.fetchall()
|
||||
|
||||
def fetchone(self) -> Tuple:
|
||||
return self.txn.fetchone()
|
||||
|
||||
def __iter__(self) -> Iterator[Tuple]:
|
||||
return self.txn.__iter__()
|
||||
|
||||
|
@ -754,6 +757,7 @@ class DatabasePool:
|
|||
Returns:
|
||||
A list of dicts where the key is the column header.
|
||||
"""
|
||||
assert cursor.description is not None, "cursor.description was None"
|
||||
col_headers = [intern(str(column[0])) for column in cursor.description]
|
||||
results = [dict(zip(col_headers, row)) for row in cursor]
|
||||
return results
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue