mirror of
https://github.com/zulip/zulip.git
synced 2025-11-01 20:44:04 +00:00
python: Remove unnecessary NonBinaryStr TypeVar.
This was a potentially useful value (later superceded by use of Text) when first introduced, but now that we're on Python 3, it should just be str.
This commit is contained in:
@@ -4,7 +4,6 @@ from psycopg2.extensions import cursor, connection
|
||||
|
||||
from typing import Callable, Optional, Iterable, Any, Dict, List, Union, TypeVar, \
|
||||
Mapping
|
||||
from zerver.lib.str_utils import NonBinaryStr
|
||||
|
||||
CursorObj = TypeVar('CursorObj', bound=cursor)
|
||||
ParamsT = Union[Iterable[Any], Mapping[str, Any]]
|
||||
@@ -12,8 +11,8 @@ ParamsT = Union[Iterable[Any], Mapping[str, Any]]
|
||||
# Similar to the tracking done in Django's CursorDebugWrapper, but done at the
|
||||
# psycopg2 cursor level so it works with SQLAlchemy.
|
||||
def wrapper_execute(self: CursorObj,
|
||||
action: Callable[[NonBinaryStr, Optional[ParamsT]], CursorObj],
|
||||
sql: NonBinaryStr,
|
||||
action: Callable[[str, Optional[ParamsT]], CursorObj],
|
||||
sql: str,
|
||||
params: Optional[ParamsT]=()) -> CursorObj:
|
||||
start = time.time()
|
||||
try:
|
||||
@@ -28,11 +27,11 @@ def wrapper_execute(self: CursorObj,
|
||||
class TimeTrackingCursor(cursor):
|
||||
"""A psycopg2 cursor class that tracks the time spent executing queries."""
|
||||
|
||||
def execute(self, query: NonBinaryStr,
|
||||
def execute(self, query: str,
|
||||
vars: Optional[ParamsT]=None) -> 'TimeTrackingCursor':
|
||||
return wrapper_execute(self, super().execute, query, vars)
|
||||
|
||||
def executemany(self, query: NonBinaryStr,
|
||||
def executemany(self, query: str,
|
||||
vars: Iterable[Any]) -> 'TimeTrackingCursor':
|
||||
return wrapper_execute(self, super().executemany, query, vars)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user