]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
fix lint and mypy errors
authorYurii Karabas <1998uriyyo@gmail.com>
Tue, 14 Nov 2023 16:09:15 +0000 (18:09 +0200)
committerYurii Karabas <1998uriyyo@gmail.com>
Tue, 14 Nov 2023 16:09:15 +0000 (18:09 +0200)
lib/sqlalchemy/engine/cursor.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/result.py
lib/sqlalchemy/engine/row.py
lib/sqlalchemy/ext/horizontal_shard.py
lib/sqlalchemy/sql/util.py

index b3828361f7597b0eb3206896c8ef49d59370129b..dae898e6283036f713363ff68f2356ba26137d56 100644 (file)
@@ -28,7 +28,6 @@ from typing import Optional
 from typing import Sequence
 from typing import Tuple
 from typing import TYPE_CHECKING
-from typing import TypeVar
 from typing import Union
 
 from .result import IteratorResult
@@ -346,7 +345,7 @@ class CursorResultMetaData(ResultMetaData):
 
     def __init__(
         self,
-        parent: CursorResult[Any],
+        parent: CursorResult[Unpack[Tuple[Any, ...]]],
         cursor_description: _DBAPICursorDescription,
     ):
         context = parent.context
@@ -930,18 +929,22 @@ class ResultFetchStrategy:
     alternate_cursor_description: Optional[_DBAPICursorDescription] = None
 
     def soft_close(
-        self, result: CursorResult[Any], dbapi_cursor: Optional[DBAPICursor]
+        self,
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
+        dbapi_cursor: Optional[DBAPICursor],
     ) -> None:
         raise NotImplementedError()
 
     def hard_close(
-        self, result: CursorResult[Any], dbapi_cursor: Optional[DBAPICursor]
+        self,
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
+        dbapi_cursor: Optional[DBAPICursor],
     ) -> None:
         raise NotImplementedError()
 
     def yield_per(
         self,
-        result: CursorResult[Any],
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
         dbapi_cursor: Optional[DBAPICursor],
         num: int,
     ) -> None:
@@ -949,7 +952,7 @@ class ResultFetchStrategy:
 
     def fetchone(
         self,
-        result: CursorResult[Any],
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
         dbapi_cursor: DBAPICursor,
         hard_close: bool = False,
     ) -> Any:
@@ -957,7 +960,7 @@ class ResultFetchStrategy:
 
     def fetchmany(
         self,
-        result: CursorResult[Any],
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
         dbapi_cursor: DBAPICursor,
         size: Optional[int] = None,
     ) -> Any:
@@ -965,14 +968,14 @@ class ResultFetchStrategy:
 
     def fetchall(
         self,
-        result: CursorResult[Any],
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
         dbapi_cursor: DBAPICursor,
     ) -> Any:
         raise NotImplementedError()
 
     def handle_exception(
         self,
-        result: CursorResult[Any],
+        result: CursorResult[Unpack[Tuple[Any, ...]]],
         dbapi_cursor: Optional[DBAPICursor],
         err: BaseException,
     ) -> NoReturn:
@@ -2110,7 +2113,9 @@ class CursorResult(Result[Unpack[_Ts]]):
     def _raw_row_iterator(self):
         return self._fetchiter_impl()
 
-    def merge(self, *others: Result[Unpack[Tuple[Any, ...]]]) -> MergedResult[Unpack[Tuple[Any, ...]]]:
+    def merge(
+        self, *others: Result[Unpack[Tuple[Any, ...]]]
+    ) -> MergedResult[Unpack[Tuple[Any, ...]]]:
         merged_result = super().merge(*others)
         setup_rowcounts = self.context._has_rowcount
         if setup_rowcounts:
index bd55dd95c3f96bd3a8b8a782d229eb58a089c790..b1bc37c840cfe5ec0a20dce1e25adeac6af581b9 100644 (file)
@@ -1183,7 +1183,9 @@ class DefaultExecutionContext(ExecutionContext):
     result_column_struct: Optional[
         Tuple[List[ResultColumnsEntry], bool, bool, bool, bool]
     ] = None
-    returned_default_rows: Optional[Sequence[Row[Unpack[Tuple[Any, ...]]]]] = None
+    returned_default_rows: Optional[
+        Sequence[Row[Unpack[Tuple[Any, ...]]]]
+    ] = None
 
     execution_options: _ExecuteOptions = util.EMPTY_DICT
 
index 07689564a49c51284a36c7948fbebcce9bd2ec0d..5e536323ee01664c1226eb195a0ddfc20f3d1d63 100644 (file)
@@ -45,8 +45,8 @@ from ..util import NONE_SET
 from ..util._has_cy import HAS_CYEXTENSION
 from ..util.typing import Literal
 from ..util.typing import Self
-from ..util.typing import Unpack
 from ..util.typing import TypeVarTuple
+from ..util.typing import Unpack
 
 if typing.TYPE_CHECKING or not HAS_CYEXTENSION:
     from ._py_row import tuplegetter as tuplegetter
@@ -1352,7 +1352,9 @@ class Result(_WithKeys, ResultInternal[Row[Unpack[_Ts]]]):
         else:
             return row
 
-    def fetchmany(self, size: Optional[int] = None) -> Sequence[Row[Unpack[_Ts]]]:
+    def fetchmany(
+        self, size: Optional[int] = None
+    ) -> Sequence[Row[Unpack[_Ts]]]:
         """Fetch many rows.
 
         When all rows are exhausted, returns an empty list.
@@ -1588,7 +1590,9 @@ class Result(_WithKeys, ResultInternal[Row[Unpack[_Ts]]]):
 
         return FrozenResult(self)
 
-    def merge(self, *others: Result[Any]) -> MergedResult[Unpack[_Ts]]:
+    def merge(
+        self, *others: Result[Unpack[_RawRowType]]
+    ) -> MergedResult[Unpack[_RawRowType]]:
         """Merge this :class:`_engine.Result` with other compatible result
         objects.
 
@@ -1723,7 +1727,9 @@ class ScalarResult(FilterResult[_R]):
 
     _post_creational_filter: Optional[Callable[[Any], Any]]
 
-    def __init__(self, real_result: Result[Unpack[_RawRowType]], index: _KeyIndexType):
+    def __init__(
+        self, real_result: Result[Unpack[_RawRowType]], index: _KeyIndexType
+    ):
         self._real_result = real_result
 
         if real_result._source_supports_scalars:
@@ -2381,7 +2387,9 @@ class MergedResult(IteratorResult[Unpack[_Ts]]):
     rowcount: Optional[int]
 
     def __init__(
-        self, cursor_metadata: ResultMetaData, results: Sequence[Result[Unpack[_Ts]]]
+        self,
+        cursor_metadata: ResultMetaData,
+        results: Sequence[Result[Unpack[_Ts]]],
     ):
         self._results = results
         super().__init__(
index 7e357bb6e69eaa812e99399e2d6b284e9f7712b2..bb920ead4a31af49714a99d125eeef27e5f569fe 100644 (file)
@@ -22,18 +22,16 @@ from typing import List
 from typing import Mapping
 from typing import NoReturn
 from typing import Optional
-from typing import overload
 from typing import Sequence
 from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import TypeVar
-from typing import Union
 
 from ..sql import util as sql_util
 from ..util import deprecated
+from ..util._has_cy import HAS_CYEXTENSION
 from ..util.typing import TypeVarTuple
 from ..util.typing import Unpack
-from ..util._has_cy import HAS_CYEXTENSION
 
 if TYPE_CHECKING or not HAS_CYEXTENSION:
     from ._py_row import BaseRow as BaseRow
@@ -41,10 +39,11 @@ else:
     from sqlalchemy.cyextension.resultproxy import BaseRow as BaseRow
 
 if TYPE_CHECKING:
+    from typing import Tuple as _RowBase
+
     from .result import _KeyType
     from .result import _ProcessorsType
     from .result import RMKeyView
-    from typing import Tuple as _RowBase
 else:
     _RowBase = Sequence
 
index 25b897176f0f1313624f5447bb0c2e97b1fee180..2d0c884943052ebd96db0ab487bade675e5a2a72 100644 (file)
@@ -69,7 +69,6 @@ if TYPE_CHECKING:
     from ..orm.session import ORMExecuteState
     from ..orm.state import InstanceState
     from ..sql import Executable
-    from ..sql._typing import _TP
     from ..sql.elements import ClauseElement
 
 __all__ = ["ShardedSession", "ShardedQuery"]
index 15e7da265710b282ebffe4bc875e478d987e75dc..62914fbaa119de1d0107c5cfa1f0b4582785cb4e 100644 (file)
@@ -589,7 +589,9 @@ class _repr_row(_repr_base):
 
     __slots__ = ("row",)
 
-    def __init__(self, row: Row[Unpack[Tuple[Any, ...]]], max_chars: int = 300):
+    def __init__(
+        self, row: Row[Unpack[Tuple[Any, ...]]], max_chars: int = 300
+    ):
         self.row = row
         self.max_chars = max_chars