Fixed typing issue where the argument list passed to :class:`.Values` was
too-restrictively tied to ``List`` rather than ``Sequence``. Pull request
courtesy Iuri de Silvio.
Fixes: #10451
Closes: #10452
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/10452
Pull-request-sha:
7800f0d631f75b716b8870755e5d0a3fbe950277
Change-Id: If631455d049b2308ec42602b72a60a5ede35fa32
--- /dev/null
+.. change::
+ :tags: bug, typing
+ :tickets: 10451
+
+ Fixed typing issue where the argument list passed to :class:`.Values` was
+ too-restrictively tied to ``List`` rather than ``Sequence``. Pull request
+ courtesy Iuri de Silvio.
__visit_name__ = "values"
- _data: Tuple[List[Tuple[Any, ...]], ...] = ()
+ _data: Tuple[Sequence[Tuple[Any, ...]], ...] = ()
_unnamed: bool
_traverse_internals: _TraverseInternalsType = [
return self
@_generative
- def data(self, values: List[Tuple[Any, ...]]) -> Self:
+ def data(self, values: Sequence[Tuple[Any, ...]]) -> Self:
"""Return a new :class:`_expression.Values` construct,
adding the given data to the data list.
def __init__(
self,
columns: Sequence[ColumnClause[Any]],
- data: Tuple[List[Tuple[Any, ...]], ...],
+ data: Tuple[Sequence[Tuple[Any, ...]], ...],
literal_binds: bool,
):
super().__init__()
Book.append_column(sa.column("other"))
Book.corresponding_column(Book.c.id)
-value_expr = sa.values(
+values = sa.values(
sa.column("id", sa.Integer), sa.column("name", sa.String), name="my_values"
-).data([(1, "name1"), (2, "name2"), (3, "name3")])
+)
+value_expr = values.data([(1, "name1"), (2, "name2"), (3, "name3")])
+
+data: list[tuple[int, str]] = [(1, "name1"), (2, "name2"), (3, "name3")]
+value_expr2 = values.data(data)
sa.select(Book)
sa.select(sa.literal_column("42"), sa.column("foo")).select_from(sa.table("t"))