_KeyMapType = Mapping[_KeyType, _KeyMapRecType]
-_RowData = Union[Row[Any], RowMapping, Any]
+_RowData = Union[Row[Unpack[Tuple[Any, ...]]], RowMapping, Any]
"""A generic form of "row" that accommodates for the different kinds of
"rows" that different result objects return, including row, row mapping, and
scalar values"""
"""
-_InterimSupportsScalarsRowType = Union[Row[Any], Any]
+_InterimSupportsScalarsRowType = Union[Row[Unpack[_RawRowType]], Any]
_ProcessorsType = Sequence[Optional["_ResultProcessorType[Any]"]]
_TupleGetterType = Callable[[Sequence[Any]], Sequence[Any]]
def _getter(
self, key: Any, raiseerr: bool = True
- ) -> Optional[Callable[[Row[Any]], Any]]:
+ ) -> Optional[Callable[[Row[Unpack[Tuple[Any, ...]]]], Any]]:
index = self._index_for_key(key, raiseerr)
if index is not None:
_tuplefilter=_tuplefilter,
)
- def _contains(self, value: Any, row: Row[Any]) -> bool:
+ def _contains(self, value: Any, row: Row[Unpack[_RawRowType]]) -> bool:
return value in row._data
def _index_for_key(self, key: Any, raiseerr: bool = True) -> int:
_source_supports_scalars: bool
- def _fetchiter_impl(self) -> Iterator[_InterimRowType[Row[Any]]]:
+ def _fetchiter_impl(
+ self,
+ ) -> Iterator[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
raise NotImplementedError()
def _fetchone_impl(
self, hard_close: bool = False
- ) -> Optional[_InterimRowType[Row[Any]]]:
+ ) -> Optional[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
raise NotImplementedError()
def _fetchmany_impl(
self, size: Optional[int] = None
- ) -> List[_InterimRowType[Row[Any]]]:
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
raise NotImplementedError()
- def _fetchall_impl(self) -> List[_InterimRowType[Row[Any]]]:
+ def _fetchall_impl(
+ self,
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
raise NotImplementedError()
def _soft_close(self, hard: bool = False) -> None:
processors: Optional[_ProcessorsType],
key_to_index: Mapping[_KeyType, int],
scalar_obj: Any,
- ) -> Row[Any]:
+ ) -> Row[Unpack[_RawRowType]]:
return _proc(
metadata, processors, key_to_index, (scalar_obj,)
)
fixed_tf = tf
- def make_row(row: _InterimRowType[Row[Any]]) -> _R:
+ def make_row(
+ row: _InterimRowType[Row[Unpack[Tuple[Any, ...]]]]
+ ) -> _R:
return _make_row_orig(fixed_tf(row))
else:
_log_row = real_result._row_logging_fn
_make_row = make_row
- def make_row(row: _InterimRowType[Row[Any]]) -> _R:
+ def make_row(
+ row: _InterimRowType[Row[Unpack[Tuple[Any, ...]]]]
+ ) -> _R:
return _log_row(_make_row(row)) # type: ignore
return make_row
__slots__ = ("_metadata", "__dict__")
- _row_logging_fn: Optional[Callable[[Row[Any]], Row[Any]]] = None
+ _row_logging_fn: Optional[
+ Callable[[Row[Unpack[Tuple[Any, ...]]]], Row[Unpack[Tuple[Any, ...]]]]
+ ] = None
_source_supports_scalars: bool = False
def _getter(
self, key: _KeyIndexType, raiseerr: bool = True
- ) -> Optional[Callable[[Row[Any]], Any]]:
+ ) -> Optional[Callable[[Row[Unpack[Tuple[Any, ...]]]], Any]]:
"""return a callable that will retrieve the given key from a
:class:`_engine.Row`.
def _attributes(self) -> Dict[Any, Any]:
return self._real_result._attributes
- def _fetchiter_impl(self) -> Iterator[_InterimRowType[Row[Any]]]:
+ def _fetchiter_impl(
+ self,
+ ) -> Iterator[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
return self._real_result._fetchiter_impl()
def _fetchone_impl(
self, hard_close: bool = False
- ) -> Optional[_InterimRowType[Row[Any]]]:
+ ) -> Optional[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
return self._real_result._fetchone_impl(hard_close=hard_close)
- def _fetchall_impl(self) -> List[_InterimRowType[Row[Any]]]:
+ def _fetchall_impl(
+ self,
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
return self._real_result._fetchall_impl()
def _fetchmany_impl(
self, size: Optional[int] = None
- ) -> List[_InterimRowType[Row[Any]]]:
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
return self._real_result._fetchmany_impl(size=size)
def _fetchone_impl(
self, hard_close: bool = False
- ) -> Optional[_InterimRowType[Row[Any]]]:
+ ) -> Optional[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
if self._hard_closed:
self._raise_hard_closed()
else:
return row
- def _fetchall_impl(self) -> List[_InterimRowType[Row[Any]]]:
+ def _fetchall_impl(
+ self,
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
if self._hard_closed:
self._raise_hard_closed()
try:
def _fetchmany_impl(
self, size: Optional[int] = None
- ) -> List[_InterimRowType[Row[Any]]]:
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
if self._hard_closed:
self._raise_hard_closed()
def _fetchmany_impl(
self, size: Optional[int] = None
- ) -> List[_InterimRowType[Row[Any]]]:
+ ) -> List[_InterimRowType[Row[Unpack[Tuple[Any, ...]]]]]:
if self.dynamic_yield_per:
self.iterator = itertools.chain.from_iterable(self.chunks(size))
return super()._fetchmany_impl(size=size)
ident: Union[Any, Tuple[Any, ...]] = None,
*,
instance: Optional[Any] = None,
- row: Optional[Union[Row[Any], RowMapping]] = None,
+ row: Optional[Union[Row[Unpack[Tuple[Any, ...]]], RowMapping]] = None,
identity_token: Optional[Any] = None,
) -> _IdentityKeyType[Any]:
r"""Return an identity key.
ident: Union[Any, Tuple[Any, ...]] = None,
*,
instance: Optional[Any] = None,
- row: Optional[Union[Row[Any], RowMapping]] = None,
+ row: Optional[Union[Row[Unpack[Tuple[Any, ...]]], RowMapping]] = None,
identity_token: Optional[Any] = None,
) -> _IdentityKeyType[Any]:
r"""Return an identity key.
from ..util.typing import is_fwd_ref
from ..util.typing import is_pep593
from ..util.typing import typing_get_args
+from ..util.typing import Unpack
+
if typing.TYPE_CHECKING:
from ._typing import _InstanceDict
def create_row_processor(
self,
query: Select[Any],
- procs: Sequence[Callable[[Row[Any]], Any]],
+ procs: Sequence[Callable[[Row[Unpack[Tuple[Any, ...]]]], Any]],
labels: Sequence[str],
- ) -> Callable[[Row[Any]], Any]:
- def proc(row: Row[Any]) -> Any:
+ ) -> Callable[[Row[Unpack[Tuple[Any, ...]]]], Any]:
+ def proc(row: Row[Unpack[Tuple[Any, ...]]]) -> Any:
return self.property.composite_class(
*[proc(row) for proc in procs]
)
from ..util import HasMemoized
from ..util import HasMemoized_ro_memoized_attribute
from ..util.typing import Literal
+from ..util.typing import Unpack
if TYPE_CHECKING:
from ._typing import _IdentityKeyType
def identity_key_from_row(
self,
- row: Optional[Union[Row[Any], RowMapping]],
+ row: Optional[Union[Row[Unpack[Tuple[Any, ...]]], RowMapping]],
identity_token: Optional[Any] = None,
adapter: Optional[ORMAdapter] = None,
) -> _IdentityKeyType[_O]:
ident: Union[Any, Tuple[Any, ...]] = None,
*,
instance: Optional[Any] = None,
- row: Optional[Union[Row[Any], RowMapping]] = None,
+ row: Optional[Union[Row[Unpack[Tuple[Any, ...]]], RowMapping]] = None,
identity_token: Optional[Any] = None,
) -> _IdentityKeyType[Any]:
r"""Return an identity key.
ident: Union[Any, Tuple[Any, ...]] = None,
*,
instance: Optional[Any] = None,
- row: Optional[Union[Row[Any], RowMapping]] = None,
+ row: Optional[Union[Row[Unpack[Tuple[Any, ...]]], RowMapping]] = None,
identity_token: Optional[Any] = None,
) -> _IdentityKeyType[Any]:
"""Return an identity key.
from .. import util
from ..util.typing import Literal
from ..util.typing import Protocol
+from ..util.typing import Unpack
if TYPE_CHECKING:
from ._typing import _IdentityKeyType
"""
def __call__(
- self, state: InstanceState[_O], dict_: _InstanceDict, row: Row[Any]
+ self,
+ state: InstanceState[_O],
+ dict_: _InstanceDict,
+ row: Row[Unpack[Tuple[Any, ...]]],
) -> None:
...
fixed_impl = impl
def _set_callable(
- state: InstanceState[_O], dict_: _InstanceDict, row: Row[Any]
+ state: InstanceState[_O],
+ dict_: _InstanceDict,
+ row: Row[Unpack[Tuple[Any, ...]]],
) -> None:
if "callables" not in state.__dict__:
state.callables = {}
else:
def _set_callable(
- state: InstanceState[_O], dict_: _InstanceDict, row: Row[Any]
+ state: InstanceState[_O],
+ dict_: _InstanceDict,
+ row: Row[Unpack[Tuple[Any, ...]]],
) -> None:
if "callables" not in state.__dict__:
state.callables = {}
from ..util.typing import Literal
from ..util.typing import Protocol
from ..util.typing import typing_get_origin
+from ..util.typing import Unpack
if typing.TYPE_CHECKING:
from ._typing import _EntityType
ident: Union[Any, Tuple[Any, ...]] = None,
*,
instance: Optional[_T] = None,
- row: Optional[Union[Row[Any], RowMapping]] = None,
+ row: Optional[Union[Row[Unpack[Tuple[Any, ...]]], RowMapping]] = None,
identity_token: Optional[Any] = None,
) -> _IdentityKeyType[_T]:
r"""Generate "identity key" tuples, as are used as keys in the
def create_row_processor(
self,
query: Select[Any],
- procs: Sequence[Callable[[Row[Any]], Any]],
+ procs: Sequence[Callable[[Row[Unpack[Tuple[Any, ...]]]], Any]],
labels: Sequence[str],
- ) -> Callable[[Row[Any]], Any]:
+ ) -> Callable[[Row[Unpack[Tuple[Any, ...]]]], Any]:
"""Produce the "row processing" function for this :class:`.Bundle`.
May be overridden by subclasses to provide custom behaviors when
"""
keyed_tuple = result_tuple(labels, [() for l in labels])
- def proc(row: Row[Any]) -> Any:
+ def proc(row: Row[Unpack[Tuple[Any, ...]]]) -> Any:
return keyed_tuple([proc(row) for proc in procs])
return proc