Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions

View File

@@ -1,10 +1,10 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from _typeshed.dbapi import DBAPIConnection
from abc import abstractmethod
from collections.abc import Callable, Mapping
from types import TracebackType
from typing import Any, TypeVar, overload
from typing_extensions import Concatenate, ParamSpec, TypeAlias
from typing_extensions import Concatenate, ParamSpec, Self, TypeAlias
from ..log import Identified, _EchoFlag, echo_property
from ..pool import Pool
@@ -40,7 +40,7 @@ class Connection(Connectable):
_allow_revalidate: bool = ...,
) -> None: ...
def schema_for_object(self, obj) -> str | None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...

View File

@@ -1,7 +1,7 @@
from _typeshed import Self
from abc import abstractmethod
from collections.abc import Mapping
from typing import Any, overload
from typing_extensions import Self
from .base import _Executable
from .cursor import CursorResult
@@ -11,7 +11,7 @@ from .url import URL
class MockConnection(Connectable):
def __init__(self, dialect: Dialect, execute) -> None: ...
@property
def engine(self: Self) -> Self: ... # type: ignore[override]
def engine(self) -> Self: ... # type: ignore[override]
@property
def dialect(self) -> Dialect: ...
@property

View File

@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Generator, KeysView
from typing import Any
from typing_extensions import Self
from ..sql.base import InPlaceGenerative
from .row import Row
@@ -38,8 +39,8 @@ class _WithKeys:
class Result(_WithKeys, ResultInternal):
def __init__(self, cursor_metadata) -> None: ...
def close(self) -> None: ...
def yield_per(self: Self, num: int) -> Self: ...
def unique(self: Self, strategy: Incomplete | None = ...) -> Self: ...
def yield_per(self, num: int) -> Self: ...
def unique(self, strategy: Incomplete | None = ...) -> Self: ...
def columns(self, *col_expressions): ...
def scalars(self, index: int = ...) -> ScalarResult: ...
def mappings(self) -> MappingResult: ...

View File

@@ -1,7 +1,7 @@
from _typeshed import Self, SupportsItems
from _typeshed import SupportsItems
from collections.abc import Iterable, Mapping, Sequence
from typing import Any, NamedTuple
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias
from ..util import immutabledict
from .interfaces import Dialect
@@ -31,7 +31,7 @@ class URL(_URLTuple):
query: _Query | None = ...,
) -> URL: ...
def set(
self: Self,
self,
drivername: str | None = ...,
username: str | None = ...,
password: str | object | None = ...,
@@ -40,16 +40,16 @@ class URL(_URLTuple):
database: str | None = ...,
query: _Query | None = ...,
) -> Self: ...
def update_query_string(self: Self, query_string: str, append: bool = ...) -> Self: ...
def update_query_pairs(self: Self, key_value_pairs: Iterable[tuple[str, str]], append: bool = ...) -> Self: ...
def update_query_dict(self: Self, query_parameters: SupportsItems[str, str | Sequence[str]], append: bool = ...) -> Self: ...
def update_query_string(self, query_string: str, append: bool = ...) -> Self: ...
def update_query_pairs(self, key_value_pairs: Iterable[tuple[str, str]], append: bool = ...) -> Self: ...
def update_query_dict(self, query_parameters: SupportsItems[str, str | Sequence[str]], append: bool = ...) -> Self: ...
def difference_update_query(self, names: Iterable[str]) -> URL: ...
@property
def normalized_query(self) -> immutabledict[str, tuple[str, ...]]: ...
def __to_string__(self, hide_password: bool = ...) -> str: ...
def render_as_string(self, hide_password: bool = ...) -> str: ...
def __copy__(self: Self) -> Self: ...
def __deepcopy__(self: Self, memo: object) -> Self: ...
def __copy__(self) -> Self: ...
def __deepcopy__(self, memo: object) -> Self: ...
def __hash__(self) -> int: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...

View File

@@ -1,12 +1,12 @@
from _typeshed import Self
from collections.abc import Callable
from types import TracebackType
from typing import Any
from typing_extensions import Self
def connection_memoize(key: str) -> Callable[..., Any]: ...
class TransactionalContext:
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...

View File

@@ -1,5 +1,6 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from typing import Any
from typing_extensions import Self
from ...util import memoized_property
from .base import ReversibleProxy, StartableContext
@@ -53,7 +54,7 @@ class AsyncSession(ReversibleProxy):
async def close(self): ...
@classmethod
async def close_all(cls): ...
async def __aenter__(self: Self) -> Self: ...
async def __aenter__(self) -> Self: ...
async def __aexit__(self, type_, value, traceback) -> None: ...
# proxied from Session
identity_map: Any

View File

@@ -1,7 +1,6 @@
from _typeshed import Self
from logging import Logger
from typing import Any, TypeVar, overload
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
_ClsT = TypeVar("_ClsT", bound=type)
_EchoFlag: TypeAlias = bool | Literal["debug"] | None
@@ -33,7 +32,7 @@ def instance_logger(instance: Identified, echoflag: _EchoFlag = ...) -> None: ..
class echo_property:
__doc__: str
@overload
def __get__(self: Self, instance: None, owner: object) -> Self: ...
def __get__(self, instance: None, owner: object) -> Self: ...
@overload
def __get__(self, instance: Identified, owner: object) -> _EchoFlag: ...
def __set__(self, instance: Identified, value: _EchoFlag) -> None: ...

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Iterator
from typing import Any, Generic, TypeVar
from typing_extensions import Literal, TypeAlias
from typing_extensions import Literal, Self, TypeAlias
from ..sql.annotation import SupportsCloneAnnotations
from ..sql.base import Executable
@@ -30,74 +30,69 @@ class Query(_SelectFromElements, SupportsCloneAnnotations, HasPrefixes, HasSuffi
@property
def selectable(self): ...
def __clause_element__(self): ...
def only_return_tuples(self: Self, value) -> Self: ...
def only_return_tuples(self, value) -> Self: ...
@property
def is_single_entity(self): ...
def enable_eagerloads(self: Self, value) -> Self: ...
def enable_eagerloads(self, value) -> Self: ...
def with_labels(self): ...
apply_labels: Any
@property
def get_label_style(self): ...
def set_label_style(self, style): ...
def enable_assertions(self: Self, value) -> Self: ...
def enable_assertions(self, value) -> Self: ...
@property
def whereclause(self): ...
def with_polymorphic(
self: Self, cls_or_mappers, selectable: Incomplete | None = ..., polymorphic_on: Incomplete | None = ...
self, cls_or_mappers, selectable: Incomplete | None = ..., polymorphic_on: Incomplete | None = ...
) -> Self: ...
def yield_per(self: Self, count) -> Self: ...
def yield_per(self, count) -> Self: ...
def get(self, ident): ...
@property
def lazy_loaded_from(self): ...
def correlate(self: Self, *fromclauses) -> Self: ...
def autoflush(self: Self, setting) -> Self: ...
def populate_existing(self: Self) -> Self: ...
def correlate(self, *fromclauses) -> Self: ...
def autoflush(self, setting) -> Self: ...
def populate_existing(self) -> Self: ...
def with_parent(self, instance, property: Incomplete | None = ..., from_entity: Incomplete | None = ...): ...
def add_entity(self: Self, entity, alias: Incomplete | None = ...) -> Self: ...
def with_session(self: Self, session) -> Self: ...
def add_entity(self, entity, alias: Incomplete | None = ...) -> Self: ...
def with_session(self, session) -> Self: ...
def from_self(self, *entities): ...
def values(self, *columns): ...
def value(self, column): ...
def with_entities(self: Self, *entities) -> Self: ...
def add_columns(self: Self, *column) -> Self: ...
def with_entities(self, *entities) -> Self: ...
def add_columns(self, *column) -> Self: ...
def add_column(self, column): ...
def options(self: Self, *args) -> Self: ...
def options(self, *args) -> Self: ...
def with_transformation(self, fn): ...
def get_execution_options(self): ...
def execution_options(self: Self, **kwargs) -> Self: ...
def execution_options(self, **kwargs) -> Self: ...
def with_for_update(
self: Self,
read: bool = ...,
nowait: bool = ...,
of: Incomplete | None = ...,
skip_locked: bool = ...,
key_share: bool = ...,
self, read: bool = ..., nowait: bool = ..., of: Incomplete | None = ..., skip_locked: bool = ..., key_share: bool = ...
) -> Self: ...
def params(self: Self, *args, **kwargs) -> Self: ...
def params(self, *args, **kwargs) -> Self: ...
def where(self, *criterion): ...
def filter(self: Self, *criterion) -> Self: ...
def filter_by(self: Self, **kwargs) -> Self: ...
def order_by(self: Self, *clauses) -> Self: ...
def group_by(self: Self, *clauses) -> Self: ...
def having(self: Self, criterion) -> Self: ...
def filter(self, *criterion) -> Self: ...
def filter_by(self, **kwargs) -> Self: ...
def order_by(self, *clauses) -> Self: ...
def group_by(self, *clauses) -> Self: ...
def having(self, criterion) -> Self: ...
def union(self, *q): ...
def union_all(self, *q): ...
def intersect(self, *q): ...
def intersect_all(self, *q): ...
def except_(self, *q): ...
def except_all(self, *q): ...
def join(self: Self, target, *props, **kwargs) -> Self: ...
def outerjoin(self: Self, target, *props, **kwargs) -> Self: ...
def reset_joinpoint(self: Self) -> Self: ...
def select_from(self: Self, *from_obj) -> Self: ...
def select_entity_from(self: Self, from_obj) -> Self: ...
def join(self, target, *props, **kwargs) -> Self: ...
def outerjoin(self, target, *props, **kwargs) -> Self: ...
def reset_joinpoint(self) -> Self: ...
def select_from(self, *from_obj) -> Self: ...
def select_entity_from(self, from_obj) -> Self: ...
def __getitem__(self, item): ...
def slice(self: Self, start, stop) -> Self: ...
def limit(self: Self, limit) -> Self: ...
def offset(self: Self, offset) -> Self: ...
def distinct(self: Self, *expr) -> Self: ...
def slice(self, start, stop) -> Self: ...
def limit(self, limit) -> Self: ...
def offset(self, offset) -> Self: ...
def distinct(self, *expr) -> Self: ...
def all(self) -> list[_T]: ...
def from_statement(self: Self, statement) -> Self: ...
def from_statement(self, statement) -> Self: ...
def first(self) -> _T | None: ...
def one_or_none(self): ...
def one(self): ...

View File

@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Mapping
from typing import Any, TypeVar, overload
from typing_extensions import Self
from ..engine.base import Connection
from ..engine.result import Result
@@ -105,7 +106,7 @@ class Session(_SessionClassMethods):
query_cls: Incomplete | None = ...,
) -> None: ...
connection_callable: Any
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, type_, value, traceback) -> None: ...
@property
def transaction(self): ...

View File

@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import MutableMapping
from typing import Any, ClassVar
from typing_extensions import Self
from .. import util
from ..util import HasMemoized, hybridmethod, memoized_property
@@ -98,8 +99,8 @@ class Executable(roles.StatementRole, Generative):
is_text: bool
is_delete: bool
is_dml: bool
def options(self: Self, *options) -> Self: ...
def execution_options(self: Self, **kw) -> Self: ...
def options(self, *options) -> Self: ...
def execution_options(self, **kw) -> Self: ...
def get_execution_options(self): ...
def execute(self, *multiparams, **params): ...
def scalar(self, *multiparams, **params): ...

View File

@@ -1,6 +1,6 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from typing import Any, Generic, TypeVar
from typing_extensions import Literal
from typing_extensions import Literal, Self
from .. import util
from ..util import HasMemoized, memoized_property
@@ -138,7 +138,7 @@ class TextClause(
key: Any
text: Any
def __init__(self, text: str, bind: Incomplete | None = None) -> None: ...
def bindparams(self: Self, *binds, **names_to_values) -> Self: ...
def bindparams(self, *binds, **names_to_values) -> Self: ...
def columns(self, *cols, **types): ...
@property
def type(self): ...

View File

@@ -1,5 +1,6 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from typing import Any
from typing_extensions import Self
from .. import util
from ..util import HasMemoized, memoized_property
@@ -38,14 +39,14 @@ class Selectable(ReturnsRows):
def corresponding_column(self, column, require_embedded: bool = ...): ...
class HasPrefixes:
def prefix_with(self: Self, *expr, **kw) -> Self: ...
def prefix_with(self, *expr, **kw) -> Self: ...
class HasSuffixes:
def suffix_with(self: Self, *expr, **kw) -> Self: ...
def suffix_with(self, *expr, **kw) -> Self: ...
class HasHints:
def with_statement_hint(self, text, dialect_name: str = ...): ...
def with_hint(self: Self, selectable, text: str, dialect_name: str = ...) -> Self: ...
def with_hint(self, selectable, text: str, dialect_name: str = ...) -> Self: ...
class FromClause(roles.AnonymizedFromClauseRole, Selectable):
__visit_name__: str
@@ -191,9 +192,9 @@ class Values(Generative, FromClause):
name: Any
literal_binds: Any
def __init__(self, *columns, **kw) -> None: ...
def alias(self: Self, name: Incomplete | None, **kw) -> Self: ... # type: ignore[override]
def lateral(self: Self, name: Incomplete | None = ...) -> Self: ...
def data(self: Self, values) -> Self: ...
def alias(self, name: Incomplete | None, **kw) -> Self: ... # type: ignore[override]
def lateral(self, name: Incomplete | None = ...) -> Self: ...
def data(self, values) -> Self: ...
class SelectBase(
roles.SelectStatementRole,
@@ -251,22 +252,17 @@ class GenerativeSelect(DeprecatedSelectBaseGenerations, SelectBase):
bind: Incomplete | None = ...,
) -> None: ...
def with_for_update(
self: Self,
nowait: bool = ...,
read: bool = ...,
of: Incomplete | None = ...,
skip_locked: bool = ...,
key_share: bool = ...,
self, nowait: bool = ..., read: bool = ..., of: Incomplete | None = ..., skip_locked: bool = ..., key_share: bool = ...
) -> Self: ...
def get_label_style(self): ...
def set_label_style(self, style): ...
def apply_labels(self): ...
def limit(self: Self, limit: Incomplete | None) -> Self: ...
def fetch(self: Self, count: Incomplete | None, with_ties: bool = ..., percent: bool = ...) -> Self: ...
def offset(self: Self, offset: Incomplete | None) -> Self: ...
def slice(self: Self, start: Incomplete | None, stop: Incomplete | None) -> Self: ...
def order_by(self: Self, *clauses) -> Self: ...
def group_by(self: Self, *clauses) -> Self: ...
def limit(self, limit: Incomplete | None) -> Self: ...
def fetch(self, count: Incomplete | None, with_ties: bool = ..., percent: bool = ...) -> Self: ...
def offset(self, offset: Incomplete | None) -> Self: ...
def slice(self, start: Incomplete | None, stop: Incomplete | None) -> Self: ...
def order_by(self, *clauses) -> Self: ...
def group_by(self, *clauses) -> Self: ...
class CompoundSelectState(CompileState): ...
@@ -344,11 +340,9 @@ class Select(
@property
def column_descriptions(self): ...
def from_statement(self, statement): ...
def join(self: Self, target, onclause: Incomplete | None = ..., isouter: bool = ..., full: bool = ...) -> Self: ...
def join(self, target, onclause: Incomplete | None = ..., isouter: bool = ..., full: bool = ...) -> Self: ...
def outerjoin_from(self, from_, target, onclause: Incomplete | None = ..., full: bool = ...): ...
def join_from(
self: Self, from_, target, onclause: Incomplete | None = ..., isouter: bool = ..., full: bool = ...
) -> Self: ...
def join_from(self, from_, target, onclause: Incomplete | None = ..., isouter: bool = ..., full: bool = ...) -> Self: ...
def outerjoin(self, target, onclause: Incomplete | None = ..., full: bool = ...): ...
def get_final_froms(self): ...
@property
@@ -359,18 +353,18 @@ class Select(
def inner_columns(self): ...
def is_derived_from(self, fromclause): ...
def get_children(self, **kwargs): ...
def add_columns(self: Self, *columns) -> Self: ...
def add_columns(self, *columns) -> Self: ...
def column(self, column): ...
def reduce_columns(self, only_synonyms: bool = ...): ...
def with_only_columns(self: Self, *columns, **kw) -> Self: ...
def with_only_columns(self, *columns, **kw) -> Self: ...
@property
def whereclause(self): ...
def where(self: Self, *whereclause) -> Self: ...
def having(self: Self, having) -> Self: ...
def distinct(self: Self, *expr) -> Self: ...
def select_from(self: Self, *froms) -> Self: ...
def correlate(self: Self, *fromclauses) -> Self: ...
def correlate_except(self: Self, *fromclauses) -> Self: ...
def where(self, *whereclause) -> Self: ...
def having(self, having) -> Self: ...
def distinct(self, *expr) -> Self: ...
def select_from(self, *froms) -> Self: ...
def correlate(self, *fromclauses) -> Self: ...
def correlate_except(self, *fromclauses) -> Self: ...
@HasMemoized.memoized_attribute
def selected_columns(self): ...
def self_group(self, against: Incomplete | None = ...): ...
@@ -394,10 +388,10 @@ class ScalarSelect(roles.InElementRole, Generative, Grouping):
def columns(self) -> None: ...
@property
def c(self): ...
def where(self: Self, crit) -> Self: ...
def where(self, crit) -> Self: ...
def self_group(self, **kwargs): ...
def correlate(self: Self, *fromclauses) -> Self: ...
def correlate_except(self: Self, *fromclauses) -> Self: ...
def correlate(self, *fromclauses) -> Self: ...
def correlate_except(self, *fromclauses) -> Self: ...
class Exists(UnaryExpression):
inherit_cache: bool
@@ -418,7 +412,7 @@ class TextualSelect(SelectBase):
def __init__(self, text, columns, positional: bool = ...) -> None: ...
@HasMemoized.memoized_attribute
def selected_columns(self): ...
def bindparams(self: Self, *binds, **bind_as_values) -> Self: ...
def bindparams(self, *binds, **bind_as_values) -> Self: ...
TextAsFrom = TextualSelect

View File

@@ -1,7 +1,8 @@
import collections.abc
from _typeshed import Incomplete, Self, SupportsKeysAndGetItem
from _typeshed import Incomplete, SupportsKeysAndGetItem
from collections.abc import Callable, Iterable, Iterator, Mapping
from typing import Any, Generic, NoReturn, TypeVar, overload
from typing_extensions import Self
from ..cimmutabledict import immutabledict as immutabledict
@@ -82,21 +83,21 @@ class OrderedSet(set[_T], Generic[_T]):
def __getitem__(self, key: int) -> _T: ...
def __iter__(self) -> Iterator[_T]: ...
def __add__(self, other: Iterable[_S]) -> OrderedSet[_S | _T]: ...
def update(self: Self, iterable: Iterable[_T]) -> Self: ... # type: ignore[override]
def update(self, iterable: Iterable[_T]) -> Self: ... # type: ignore[override]
__ior__ = update # type: ignore[assignment]
def union(self, other: Iterable[_S]) -> OrderedSet[_S | _T]: ... # type: ignore[override]
__or__ = union # type: ignore[assignment] # pyright: ignore[reportGeneralTypeIssues]
def intersection(self: Self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__and__ = intersection # type: ignore[assignment] # pyright: ignore[reportGeneralTypeIssues]
def intersection(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__and__ = intersection
def symmetric_difference(self, other: Iterable[_S]) -> OrderedSet[_S | _T]: ...
__xor__ = symmetric_difference # type: ignore[assignment] # pyright: ignore[reportGeneralTypeIssues]
def difference(self: Self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__sub__ = difference # type: ignore[assignment] # pyright: ignore[reportGeneralTypeIssues]
def intersection_update(self: Self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
def difference(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__sub__ = difference
def intersection_update(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__iand__ = intersection_update # type: ignore[assignment]
def symmetric_difference_update(self: Self, other: Iterable[_T]) -> Self: ... # type: ignore[override]
def symmetric_difference_update(self, other: Iterable[_T]) -> Self: ... # type: ignore[override]
__ixor__ = symmetric_difference_update # type: ignore[assignment]
def difference_update(self: Self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
def difference_update(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__isub__ = difference_update # type: ignore[assignment]
class IdentitySet:

View File

@@ -1,6 +1,7 @@
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self
from . import compat
@@ -70,7 +71,7 @@ class memoized_property(Generic[_R]):
__name__: str
def __init__(self, fget: Callable[..., _R], doc: str | None = ...) -> None: ...
@overload
def __get__(self: Self, obj: None, cls: object) -> Self: ...
def __get__(self, obj: None, cls: object) -> Self: ...
@overload
def __get__(self, obj: object, cls: object) -> _R: ...
@classmethod
@@ -85,7 +86,7 @@ class HasMemoized:
__name__: str
def __init__(self, fget: Callable[..., _R], doc: str | None = ...) -> None: ...
@overload
def __get__(self: Self, obj: None, cls: object) -> Self: ...
def __get__(self, obj: None, cls: object) -> Self: ...
@overload
def __get__(self, obj: object, cls: object) -> _R: ...
@@ -119,7 +120,7 @@ class hybridproperty(Generic[_R]):
def __get__(self, instance: None, owner: Any) -> _R: ...
@overload
def __get__(self, instance: object, owner: object) -> _R: ...
def classlevel(self: Self, func: Callable[..., _R]) -> Self: ...
def classlevel(self, func: Callable[..., _R]) -> Self: ...
class hybridmethod:
func: Any