Skip to content

Commit 754f421

Browse files
authored
SQLAlchemy improvements for generative methods (#7603)
1 parent ef819f3 commit 754f421

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

stubs/SQLAlchemy/sqlalchemy/ext/asyncio/engine.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ from typing import Any
22

33
from .base import ProxyComparable, StartableContext
44

5-
def create_async_engine(*arg, **kw): ...
5+
def create_async_engine(*arg, **kw) -> AsyncEngine: ...
66

77
class AsyncConnectable: ...
88

stubs/SQLAlchemy/sqlalchemy/sql/selectable.pyi

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Self
12
from typing import Any
23

34
from .. import util
@@ -37,14 +38,14 @@ class Selectable(ReturnsRows):
3738
def corresponding_column(self, column, require_embedded: bool = ...): ...
3839

3940
class HasPrefixes:
40-
def prefix_with(self, *expr, **kw) -> None: ...
41+
def prefix_with(self: Self, *expr, **kw) -> Self: ...
4142

4243
class HasSuffixes:
43-
def suffix_with(self, *expr, **kw) -> None: ...
44+
def suffix_with(self: Self, *expr, **kw) -> Self: ...
4445

4546
class HasHints:
4647
def with_statement_hint(self, text, dialect_name: str = ...): ...
47-
def with_hint(self, selectable, text, dialect_name: str = ...) -> None: ...
48+
def with_hint(self: Self, selectable, text: str, dialect_name: str = ...) -> Self: ...
4849

4950
class FromClause(roles.AnonymizedFromClauseRole, Selectable):
5051
__visit_name__: str
@@ -190,9 +191,9 @@ class Values(Generative, FromClause):
190191
name: Any
191192
literal_binds: Any
192193
def __init__(self, *columns, **kw) -> None: ...
193-
def alias(self, name, **kw) -> None: ... # type: ignore[override]
194-
def lateral(self, name: Any | None = ...) -> None: ...
195-
def data(self, values) -> None: ...
194+
def alias(self: Self, name: Any | None, **kw) -> Self: ... # type: ignore[override]
195+
def lateral(self: Self, name: Any | None = ...) -> Self: ...
196+
def data(self: Self, values) -> Self: ...
196197

197198
class SelectBase(
198199
roles.SelectStatementRole,
@@ -250,17 +251,17 @@ class GenerativeSelect(DeprecatedSelectBaseGenerations, SelectBase):
250251
bind: Any | None = ...,
251252
) -> None: ...
252253
def with_for_update(
253-
self, nowait: bool = ..., read: bool = ..., of: Any | None = ..., skip_locked: bool = ..., key_share: bool = ...
254-
) -> None: ...
254+
self: Self, nowait: bool = ..., read: bool = ..., of: Any | None = ..., skip_locked: bool = ..., key_share: bool = ...
255+
) -> Self: ...
255256
def get_label_style(self): ...
256257
def set_label_style(self, style): ...
257258
def apply_labels(self): ...
258-
def limit(self, limit) -> None: ...
259-
def fetch(self, count, with_ties: bool = ..., percent: bool = ...) -> None: ...
260-
def offset(self, offset) -> None: ...
261-
def slice(self, start, stop) -> None: ...
262-
def order_by(self, *clauses) -> None: ...
263-
def group_by(self, *clauses) -> None: ...
259+
def limit(self: Self, limit: Any | None) -> Self: ...
260+
def fetch(self: Self, count: Any | None, with_ties: bool = ..., percent: bool = ...) -> Self: ...
261+
def offset(self: Self, offset: Any | None) -> Self: ...
262+
def slice(self: Self, start: Any | None, stop: Any | None) -> Self: ...
263+
def order_by(self: Self, *clauses) -> Self: ...
264+
def group_by(self: Self, *clauses) -> Self: ...
264265

265266
class CompoundSelectState(CompileState): ...
266267

@@ -338,9 +339,9 @@ class Select(
338339
@property
339340
def column_descriptions(self): ...
340341
def from_statement(self, statement): ...
341-
def join(self, target, onclause: Any | None = ..., isouter: bool = ..., full: bool = ...) -> None: ...
342+
def join(self: Self, target, onclause: Any | None = ..., isouter: bool = ..., full: bool = ...) -> Self: ...
342343
def outerjoin_from(self, from_, target, onclause: Any | None = ..., full: bool = ...): ...
343-
def join_from(self, from_, target, onclause: Any | None = ..., isouter: bool = ..., full: bool = ...) -> None: ...
344+
def join_from(self: Self, from_, target, onclause: Any | None = ..., isouter: bool = ..., full: bool = ...) -> Self: ...
344345
def outerjoin(self, target, onclause: Any | None = ..., full: bool = ...): ...
345346
def get_final_froms(self): ...
346347
@property
@@ -351,18 +352,18 @@ class Select(
351352
def inner_columns(self): ...
352353
def is_derived_from(self, fromclause): ...
353354
def get_children(self, **kwargs): ...
354-
def add_columns(self, *columns) -> None: ...
355+
def add_columns(self: Self, *columns) -> Self: ...
355356
def column(self, column): ...
356357
def reduce_columns(self, only_synonyms: bool = ...): ...
357-
def with_only_columns(self, *columns, **kw) -> None: ...
358+
def with_only_columns(self: Self, *columns, **kw) -> Self: ...
358359
@property
359360
def whereclause(self): ...
360-
def where(self, *whereclause) -> None: ...
361-
def having(self, having) -> None: ...
362-
def distinct(self, *expr) -> None: ...
363-
def select_from(self, *froms) -> None: ...
364-
def correlate(self, *fromclauses) -> None: ...
365-
def correlate_except(self, *fromclauses) -> None: ...
361+
def where(self: Self, *whereclause) -> Self: ...
362+
def having(self: Self, having) -> Self: ...
363+
def distinct(self: Self, *expr) -> Self: ...
364+
def select_from(self: Self, *froms) -> Self: ...
365+
def correlate(self: Self, *fromclauses) -> Self: ...
366+
def correlate_except(self: Self, *fromclauses) -> Self: ...
366367
@HasMemoized.memoized_attribute
367368
def selected_columns(self): ...
368369
def self_group(self, against: Any | None = ...): ...
@@ -386,10 +387,10 @@ class ScalarSelect(roles.InElementRole, Generative, Grouping):
386387
def columns(self) -> None: ...
387388
@property
388389
def c(self): ...
389-
def where(self, crit) -> None: ...
390+
def where(self: Self, crit) -> Self: ...
390391
def self_group(self, **kwargs): ...
391-
def correlate(self, *fromclauses) -> None: ...
392-
def correlate_except(self, *fromclauses) -> None: ...
392+
def correlate(self: Self, *fromclauses) -> Self: ...
393+
def correlate_except(self: Self, *fromclauses) -> Self: ...
393394

394395
class Exists(UnaryExpression):
395396
inherit_cache: bool
@@ -410,7 +411,7 @@ class TextualSelect(SelectBase):
410411
def __init__(self, text, columns, positional: bool = ...) -> None: ...
411412
@HasMemoized.memoized_attribute
412413
def selected_columns(self): ...
413-
def bindparams(self, *binds, **bind_as_values) -> None: ...
414+
def bindparams(self: Self, *binds, **bind_as_values) -> Self: ...
414415

415416
TextAsFrom = TextualSelect
416417

0 commit comments

Comments
 (0)