Mark SQLAlchemy stubs with ignore_missing_stub = false (#9653)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Avasam
2023-04-26 20:49:46 -04:00
committed by GitHub
parent 4930ebade4
commit 6cb8bc0ac4
98 changed files with 548 additions and 189 deletions

View File

@@ -1,3 +1,10 @@
# mypy plugin not supported in typeshed
sqlalchemy.ext.mypy.*
# test suites
sqlalchemy.testing.suite
# Leaked re-exports from the compat module
sqlalchemy.util.quote
# Expanding keyword arguments in stubs
sqlalchemy.ext.declarative.as_declarative
@@ -25,9 +32,16 @@ sqlalchemy.engine.Connection.engine
sqlalchemy.orm.Mapper.single
sqlalchemy.orm.mapper.Mapper.single
# uses @memoized_property at runtime, but we use @property for compatibility
# Uses @memoized_property at runtime, but we use @property for compatibility
sqlalchemy.engine.URL.normalized_query
sqlalchemy.engine.url.URL.normalized_query
# Uses @memoized_property, but that causes regr_test to raise 'Cannot determine type of "..." in base class "..." [misc]'
sqlalchemy.schema.SchemaItem.info
sqlalchemy.sql.elements.AnnotatedColumnElement.info
sqlalchemy.sql.elements.AnnotatedColumnElement.key
sqlalchemy.sql.elements.AnnotatedColumnElement.name
sqlalchemy.sql.elements.AnnotatedColumnElement.table
sqlalchemy.sql.schema.SchemaItem.info
# runtime has extra internal arguments that are inconsistent across micro versions
sqlalchemy.testing.engines.testing_engine
@@ -62,8 +76,10 @@ sqlalchemy.sql.quoted_name.upper
sqlalchemy.orm.ColumnProperty.Comparator.__clause_element__
sqlalchemy.orm.properties.ColumnProperty.Comparator.__clause_element__
# Same error as in stdlib due to it being re-erported
# Same error as in stdlib due to it being re-exported
sqlalchemy.dialects.mysql.asyncmy.AsyncAdapt_asyncmy_dbapi.Binary
sqlalchemy.util.compat.StringIO.seek
sqlalchemy.util.compat.StringIO.truncate
sqlalchemy.util.StringIO.seek
sqlalchemy.util.StringIO.truncate
sqlalchemy.testing.mock.patch

View File

@@ -63,5 +63,6 @@ temp_table_keyword_args(url, engine)
prepare_for_drop_tables(url, unused)
stop_test_class_outside_fixtures(url, unused, type)
get_temp_table_name(url, unused, "")
set_default_schema_on_connection(url, unused, unused)
set_default_schema_on_connection(ConfigModule, unused, unused)
set_default_schema_on_connection(config, unused, unused)

View File

@@ -7,4 +7,3 @@ obsolete_since = "2.0.0" # Released on 2023-01-26
[tool.stubtest]
stubtest_requirements = ["pytest"]
ignore_missing_stub = true

View File

@@ -84,7 +84,7 @@ from .sql import (
values as values,
within_group as within_group,
)
from .types import (
from .sql.sqltypes import (
ARRAY as ARRAY,
BIGINT as BIGINT,
BINARY as BINARY,

View File

@@ -0,0 +1,15 @@
class DecimalResultProcessor:
def __init__(self, *args, **kwargs) -> None: ...
def process(self, *args, **kwargs): ...
class UnicodeResultProcessor:
def __init__(self, *args, **kwargs) -> None: ...
def conditional_process(self, *args, **kwargs): ...
def process(self, *args, **kwargs): ...
def int_to_boolean(*args, **kwargs): ...
def str_to_date(*args, **kwargs): ...
def str_to_datetime(*args, **kwargs): ...
def str_to_time(*args, **kwargs): ...
def to_float(*args, **kwargs): ...
def to_str(*args, **kwargs): ...

View File

@@ -1,6 +1,6 @@
from typing import Any
from sqlalchemy.dialects.firebird.base import (
from .base import (
BIGINT as BIGINT,
BLOB as BLOB,
CHAR as CHAR,

View File

@@ -1,10 +1,9 @@
from _typeshed import Incomplete
from typing import Any
from sqlalchemy import sql, types as sqltypes
from sqlalchemy.engine import default
from sqlalchemy.sql import compiler
from sqlalchemy.types import (
from ...engine import default
from ...sql import compiler, sqltypes
from ...sql.sqltypes import (
BIGINT as BIGINT,
BLOB as BLOB,
DATE as DATE,
@@ -46,7 +45,7 @@ class FBTypeCompiler(compiler.GenericTypeCompiler):
def visit_CHAR(self, type_, **kw): ...
def visit_VARCHAR(self, type_, **kw): ...
class FBCompiler(sql.compiler.SQLCompiler):
class FBCompiler(compiler.SQLCompiler):
ansi_bind_rules: bool
def visit_now_func(self, fn, **kw): ...
def visit_startswith_op_binary(self, binary, operator, **kw): ...
@@ -63,12 +62,12 @@ class FBCompiler(sql.compiler.SQLCompiler):
def limit_clause(self, select, **kw): ...
def returning_clause(self, stmt, returning_cols): ...
class FBDDLCompiler(sql.compiler.DDLCompiler):
class FBDDLCompiler(compiler.DDLCompiler):
def visit_create_sequence(self, create): ...
def visit_drop_sequence(self, drop): ...
def visit_computed_column(self, generated): ...
class FBIdentifierPreparer(sql.compiler.IdentifierPreparer):
class FBIdentifierPreparer(compiler.IdentifierPreparer):
reserved_words: Any
illegal_initial_characters: Any
def __init__(self, dialect) -> None: ...

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from ...types import Float, Numeric
from ...sql.sqltypes import Float, Numeric
from .base import FBDialect, FBExecutionContext
class _kinterbasdb_numeric:

View File

@@ -2,12 +2,10 @@ from _typeshed import Incomplete
from typing import Any, overload
from typing_extensions import Literal
import sqlalchemy.types as sqltypes
from ...engine import default
from ...sql import compiler
from ...sql import compiler, sqltypes
from ...sql.elements import Cast
from ...types import (
from ...sql.sqltypes import (
BIGINT as BIGINT,
BINARY as BINARY,
CHAR as CHAR,

View File

@@ -1,7 +1,7 @@
from typing import Any
from ...sql import expression
from ...types import TypeDecorator
from ...sql.type_api import TypeDecorator
ischema: Any

View File

@@ -1,4 +1,4 @@
from ...types import JSON as _JSON
from ...sql.sqltypes import JSON as _JSON
class JSON(_JSON): ...

View File

@@ -1,6 +1,6 @@
from typing import Any
from ...types import Numeric
from ...sql.sqltypes import Numeric
from .base import MSDialect, MSIdentifierPreparer
class _MSNumeric_pymssql(Numeric):

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing import Any
from ...connectors.pyodbc import PyODBCConnector
from ...types import DateTime, Float, Numeric
from ...sql.sqltypes import DateTime, Float, Numeric
from .base import BINARY, DATETIMEOFFSET, VARBINARY, MSDialect, MSExecutionContext
class _ms_numeric_pyodbc:

View File

@@ -1,5 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from _typeshed import Incomplete, ReadableBuffer
from collections.abc import Iterable
from typing import Any, SupportsBytes
from typing_extensions import SupportsIndex
from ...engine import AdaptedConnection
from .pymysql import MySQLDialect_pymysql
@@ -51,10 +53,18 @@ class AsyncAdapt_asyncmy_connection(AdaptedConnection):
class AsyncAdaptFallback_asyncmy_connection(AsyncAdapt_asyncmy_connection):
await_: Any
def _Binary(x: Iterable[SupportsIndex] | SupportsIndex | SupportsBytes | ReadableBuffer) -> bytes: ...
class AsyncAdapt_asyncmy_dbapi:
asyncmy: Any
pymysql: Any
paramstyle: str
STRING: Incomplete
NUMBER: Incomplete
BINARY: Incomplete
DATETIME: Incomplete
TIMESTAMP: Incomplete
Binary = staticmethod(_Binary)
def __init__(self, asyncmy: Any) -> None: ...
def connect(self, *arg, **kw): ...

View File

@@ -3,9 +3,10 @@ from typing import Any
from ...engine import default
from ...sql import compiler
from ...types import BINARY as BINARY, BLOB as BLOB, BOOLEAN as BOOLEAN, DATE as DATE, VARBINARY as VARBINARY
from ...sql.sqltypes import BINARY as BINARY, BLOB as BLOB, BOOLEAN as BOOLEAN, DATE as DATE, VARBINARY as VARBINARY
from .enumerated import ENUM as ENUM, SET as SET
from .json import JSON as JSON
from .reserved_words import RESERVED_WORDS_MARIADB as RESERVED_WORDS_MARIADB, RESERVED_WORDS_MYSQL as RESERVED_WORDS_MYSQL
from .types import (
BIGINT as BIGINT,
BIT as BIT,

View File

@@ -2,7 +2,7 @@ from typing import Any
from ...sql.dml import Insert as StandardInsert
from ...sql.elements import ClauseElement
from ...util import memoized_property
from ...util.langhelpers import memoized_property
class Insert(StandardInsert):
stringify_dialect: str

View File

@@ -1,4 +1,4 @@
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
class JSON(sqltypes.JSON): ...

View File

@@ -1,6 +1,6 @@
from typing import Any
from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .base import BIT, MySQLCompiler, MySQLDialect, MySQLIdentifierPreparer
class MySQLCompiler_mysqlconnector(MySQLCompiler):

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .base import MySQLCompiler, MySQLDialect, MySQLExecutionContext
class MySQLExecutionContext_mysqldb(MySQLExecutionContext):

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .mysqldb import MySQLDialect_mysqldb
class MySQLDialect_pymysql(MySQLDialect_mysqldb):

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
class _NumericType:
unsigned: Any

View File

@@ -1,11 +1,9 @@
from _typeshed import Incomplete
from typing import Any
from sqlalchemy.sql import ClauseElement
from ...engine import default
from ...sql import compiler, sqltypes
from ...types import (
from ...sql import ClauseElement, compiler, sqltypes
from ...sql.sqltypes import (
BLOB as BLOB,
CHAR as CHAR,
CLOB as CLOB,

View File

@@ -1,8 +1,7 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
from . import base as oracle
from .base import OracleCompiler, OracleDialect, OracleExecutionContext

View File

@@ -1,9 +1,7 @@
from _typeshed import Incomplete
from typing import Any as _Any
import sqlalchemy.types as sqltypes
from ...sql import expression
from ...sql import expression, sqltypes
def Any(other, arrexpr, operator=...): ...
def All(other, arrexpr, operator=...): ...

View File

@@ -122,6 +122,7 @@ class AsyncAdapt_asyncpg_connection(AdaptedConnection):
def rollback(self) -> None: ...
def commit(self) -> None: ...
def close(self) -> None: ...
def terminate(self) -> None: ...
class AsyncAdaptFallback_asyncpg_connection(AsyncAdapt_asyncpg_connection):
await_: Any
@@ -152,6 +153,7 @@ class AsyncAdapt_asyncpg_dbapi:
TIMESTAMP: Any
TIMESTAMP_W_TZ: Any
TIME: Any
TIME_W_TZ: Incomplete
DATE: Any
INTERVAL: Any
NUMBER: Any
@@ -175,6 +177,7 @@ class PGDialect_asyncpg(PGDialect):
supports_unicode_statements: bool
supports_server_side_cursors: bool
supports_unicode_binds: bool
has_terminate: bool
default_paramstyle: str
supports_sane_multi_rowcount: bool
statement_compiler: Any

View File

@@ -5,7 +5,7 @@ from ...engine import characteristics, default, reflection
from ...schema import _CreateDropBase
from ...sql import compiler, elements, sqltypes
from ...sql.ddl import DDLBase
from ...types import (
from ...sql.sqltypes import (
BIGINT as BIGINT,
BOOLEAN as BOOLEAN,
CHAR as CHAR,
@@ -179,6 +179,7 @@ class PGTypeCompiler(compiler.GenericTypeCompiler):
def visit_INET(self, type_, **kw): ...
def visit_CIDR(self, type_, **kw): ...
def visit_MACADDR(self, type_, **kw): ...
def visit_MACADDR8(self, type_, **kw): ...
def visit_MONEY(self, type_, **kw): ...
def visit_OID(self, type_, **kw): ...
def visit_REGCLASS(self, type_, **kw): ...

View File

@@ -3,7 +3,7 @@ from typing import Any
from ...sql.dml import Insert as StandardInsert
from ...sql.elements import ClauseElement
from ...util import memoized_property
from ...util.langhelpers import memoized_property
class Insert(StandardInsert):
stringify_dialect: str

View File

@@ -1,9 +1,7 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import functions as sqlfunc
from ...sql import functions as sqlfunc, sqltypes
class HSTORE(sqltypes.Indexable, sqltypes.Concatenable, sqltypes.TypeEngine):
__visit_name__: str

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
class JSONPathType(sqltypes.JSON.JSONPathType):
def bind_processor(self, dialect): ...

View File

@@ -1,8 +1,7 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
from .array import ARRAY as PGARRAY
from .base import ENUM, INTERVAL, UUID, PGCompiler, PGDialect, PGExecutionContext, PGIdentifierPreparer
from .json import JSON, JSONB, JSONPathType

View File

@@ -1,8 +1,7 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
from .array import ARRAY as PGARRAY
from .base import ENUM, UUID, PGCompiler, PGDialect, PGExecutionContext, PGIdentifierPreparer
from .hstore import HSTORE

View File

@@ -1,6 +1,6 @@
from typing import Any
from ...types import Numeric
from ...sql.sqltypes import Numeric
from .base import UUID, PGCompiler, PGDialect, PGIdentifierPreparer
from .hstore import HSTORE
from .json import JSON, JSONB

View File

@@ -1,8 +1,7 @@
from typing import Any
import sqlalchemy.types as sqltypes
from ...util import memoized_property
from ...sql import sqltypes
from ...util.langhelpers import memoized_property
from .base import PGDialect, PGExecutionContext
class PGNumeric(sqltypes.Numeric):

View File

@@ -1,6 +1,6 @@
from typing import Any
import sqlalchemy.types as sqltypes
from ...sql import sqltypes
class RangeOperators:
class comparator_factory(sqltypes.Concatenable.Comparator[Any]):

View File

@@ -1,11 +1,9 @@
from _typeshed import Incomplete
from typing import Any
import sqlalchemy.types as sqltypes
from ...engine import default
from ...sql import compiler
from ...types import (
from ...sql import compiler, sqltypes
from ...sql.sqltypes import (
BLOB as BLOB,
BOOLEAN as BOOLEAN,
CHAR as CHAR,

View File

@@ -3,7 +3,7 @@ from typing import Any
from ...sql.dml import Insert as StandardInsert
from ...sql.elements import ClauseElement
from ...util import memoized_property
from ...util.langhelpers import memoized_property
class Insert(StandardInsert):
stringify_dialect: str

View File

@@ -1,4 +1,4 @@
from ...types import JSON as _JSON
from ...sql.sqltypes import JSON as _JSON
class JSON(_JSON): ...

View File

@@ -1,10 +1,9 @@
from _typeshed import Incomplete
from typing import Any
from sqlalchemy import types as sqltypes
from sqlalchemy.engine import default, reflection
from sqlalchemy.sql import compiler
from sqlalchemy.types import (
from ...engine import default, reflection
from ...sql import compiler, sqltypes
from ...sql.sqltypes import (
BIGINT as BIGINT,
BINARY as BINARY,
CHAR as CHAR,

View File

@@ -1,5 +1,5 @@
from sqlalchemy.connectors.mxodbc import MxODBCConnector
from sqlalchemy.dialects.sybase.base import SybaseDialect, SybaseExecutionContext
from ...connectors.mxodbc import MxODBCConnector
from .base import SybaseDialect, SybaseExecutionContext
class SybaseExecutionContext_mxodbc(SybaseExecutionContext): ...

View File

@@ -1,8 +1,8 @@
from typing import Any
from sqlalchemy import types as sqltypes
from sqlalchemy.connectors.pyodbc import PyODBCConnector
from sqlalchemy.dialects.sybase.base import SybaseDialect, SybaseExecutionContext
from ...connectors.pyodbc import PyODBCConnector
from ...sql import sqltypes
from .base import SybaseDialect, SybaseExecutionContext
class _SybNumeric_pyodbc(sqltypes.Numeric):
def bind_processor(self, dialect): ...

View File

@@ -1,8 +1,8 @@
from _typeshed import Incomplete
from typing import Any
from sqlalchemy import types as sqltypes
from sqlalchemy.dialects.sybase.base import SybaseDialect, SybaseExecutionContext, SybaseSQLCompiler
from ...sql import sqltypes
from .base import SybaseDialect, SybaseExecutionContext, SybaseSQLCompiler
class _SybNumeric(sqltypes.Numeric):
def result_processor(self, dialect, type_): ...

View File

@@ -1,14 +1,12 @@
import abc
from abc import ABC, ABCMeta, abstractmethod
from ..util import ABC
class ConnectionCharacteristic(ABC, metaclass=abc.ABCMeta):
class ConnectionCharacteristic(ABC, metaclass=ABCMeta):
transactional: bool
@abc.abstractmethod
@abstractmethod
def reset_characteristic(self, dialect, dbapi_conn): ...
@abc.abstractmethod
@abstractmethod
def set_characteristic(self, dialect, dbapi_conn, value): ...
@abc.abstractmethod
@abstractmethod
def get_characteristic(self, dialect, dbapi_conn): ...
class IsolationLevelCharacteristic(ConnectionCharacteristic):

View File

@@ -1,8 +1,9 @@
import abc
from _typeshed import Incomplete
from abc import ABCMeta
from typing import Any
from ..util import memoized_property
from ..sql.compiler import RM_NAME as RM_NAME, RM_OBJECTS as RM_OBJECTS, RM_RENDERED_NAME as RM_RENDERED_NAME, RM_TYPE as RM_TYPE
from ..util.langhelpers import memoized_property
from .result import Result, ResultMetaData
from .row import LegacyRow
@@ -128,5 +129,5 @@ ResultProxy = LegacyCursorResult
class BufferedRowResultProxy(ResultProxy): ...
class FullyBufferedResultProxy(ResultProxy): ...
class BufferedColumnRow(LegacyRow, metaclass=abc.ABCMeta): ...
class BufferedColumnRow(LegacyRow, metaclass=ABCMeta): ...
class BufferedColumnResultProxy(ResultProxy): ...

View File

@@ -1,8 +1,8 @@
from _typeshed import Incomplete
from typing import Any, ClassVar
from .. import types as sqltypes
from ..util import memoized_property
from ..sql import sqltypes
from ..util.langhelpers import memoized_property
from . import interfaces
AUTOCOMMIT_REGEXP: Any
@@ -78,6 +78,7 @@ class DefaultDialect(interfaces.Dialect): # type: ignore[misc]
CACHING_DISABLED: Any
NO_CACHE_KEY: Any
NO_DIALECT_SUPPORT: Any
has_terminate: bool
convert_unicode: Any
encoding: Any
positional: bool

View File

@@ -42,8 +42,8 @@ class Dialect:
supports_native_enum: bool
supports_native_boolean: bool
dbapi_exception_translation_map: dict[Any, Any]
supports_statement_cache: bool
dispatch: Incomplete
@abstractmethod
def create_connect_args(self, url: URL) -> None: ...
def initialize(self, connection) -> None: ...
@@ -75,6 +75,7 @@ class Dialect:
def do_begin(self, dbapi_connection) -> None: ...
def do_rollback(self, dbapi_connection) -> None: ...
def do_commit(self, dbapi_connection) -> None: ...
def do_terminate(self, dbapi_connection) -> None: ...
def do_close(self, dbapi_connection) -> None: ...
def do_set_input_sizes(self, cursor, list_of_tuples, context) -> None: ...
def create_xid(self) -> None: ...
@@ -122,6 +123,7 @@ class ExecutionContext:
def get_rowcount(self) -> None: ...
class Connectable:
dispatch: Incomplete
@abstractmethod
def connect(self, **kwargs) -> Connection: ...
@property
@@ -165,3 +167,4 @@ class ExceptionContext:
class AdaptedConnection:
@property
def driver_connection(self): ...
def run_async(self, fn): ...

View File

@@ -39,6 +39,8 @@ class _WithKeys:
class Result(_WithKeys, ResultInternal):
def __init__(self, cursor_metadata) -> None: ...
def close(self) -> None: ...
@property
def closed(self): ...
def yield_per(self, num: int) -> Self: ...
def unique(self, strategy: Incomplete | None = None) -> Self: ...
def columns(self, *col_expressions): ...
@@ -60,7 +62,11 @@ class Result(_WithKeys, ResultInternal):
def freeze(self) -> FrozenResult: ...
def merge(self, *others) -> MergedResult: ...
class FilterResult(ResultInternal): ...
class FilterResult(ResultInternal):
def yield_per(self: Self, num) -> Self: ...
@property
def closed(self): ...
def close(self) -> None: ...
class ScalarResult(FilterResult):
def __init__(self, real_result, index) -> None: ...
@@ -104,6 +110,8 @@ class IteratorResult(Result):
def __init__(
self, cursor_metadata, iterator, raw: Incomplete | None = None, _source_supports_scalars: bool = False
) -> None: ...
@property
def closed(self): ...
def null_result() -> IteratorResult: ...

View File

@@ -1,3 +1,4 @@
from abc import ABCMeta
from collections.abc import ItemsView, Iterator, KeysView, Mapping, Sequence, ValuesView
from typing import Any, Generic, TypeVar
@@ -14,7 +15,7 @@ KEY_OBJECTS_ONLY: int
KEY_OBJECTS_BUT_WARN: int
KEY_OBJECTS_NO_WARN: int
class Row(BaseRow, Sequence[Any]):
class Row(BaseRow, Sequence[Any], metaclass=ABCMeta):
# The count and index methods are inherited from Sequence.
# If the result set contains columns with the same names, these
# fields contains their respective values, instead. We don't reflect
@@ -27,6 +28,7 @@ class Row(BaseRow, Sequence[Any]):
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
def keys(self) -> list[str]: ...
def __contains__(self, key): ...
# The following methods are public, but have a leading underscore
# to prevent conflicts with column names.
@property
@@ -35,7 +37,7 @@ class Row(BaseRow, Sequence[Any]):
def _fields(self) -> tuple[str, ...]: ...
def _asdict(self) -> dict[str, Any]: ...
class LegacyRow(Row):
class LegacyRow(Row, metaclass=ABCMeta):
def has_key(self, key: str) -> bool: ...
def items(self) -> list[tuple[str, Any]]: ...
def iterkeys(self) -> Iterator[str]: ...

View File

@@ -3,7 +3,7 @@ from typing import Any
from ..orm import interfaces
from ..sql.operators import ColumnOperators
from ..util import memoized_property
from ..util.langhelpers import memoized_property
def association_proxy(target_collection, attr, **kw): ...

View File

@@ -1,14 +1,14 @@
import abc
from abc import ABC, ABCMeta, abstractmethod
from types import TracebackType
class ReversibleProxy: ...
class StartableContext(abc.ABC, metaclass=abc.ABCMeta):
@abc.abstractmethod
class StartableContext(ABC, metaclass=ABCMeta):
@abstractmethod
async def start(self, is_ctxmanager: bool = False): ...
def __await__(self): ...
async def __aenter__(self): ...
@abc.abstractmethod
@abstractmethod
async def __aexit__(
self, type_: type[BaseException] | None, value: BaseException | None, traceback: TracebackType | None
) -> None: ...

View File

@@ -5,8 +5,10 @@ from typing import Any
from .base import ProxyComparable, StartableContext
def create_async_engine(*arg, **kw) -> AsyncEngine: ...
def async_engine_from_config(configuration, prefix: str = "sqlalchemy.", **kwargs) -> AsyncEngine: ...
class AsyncConnectable: ...
class AsyncConnectable:
dispatch: Incomplete
class AsyncConnection(ProxyComparable, StartableContext, AsyncConnectable):
engine: Any

View File

@@ -3,7 +3,7 @@ from _typeshed import Incomplete
from ...engine.result import FilterResult
class AsyncCommon(FilterResult):
async def close(self) -> None: ...
async def close(self) -> None: ... # type: ignore[override] # supertype is not async
class AsyncResult(AsyncCommon):
def __init__(self, real_result) -> None: ...

View File

@@ -2,11 +2,12 @@ from _typeshed import Incomplete
from typing import Any
from ...orm.scoping import ScopedSessionMixin
from ...util import memoized_property
from ...util.langhelpers import memoized_property
class async_scoped_session(ScopedSessionMixin):
session_factory: Any
registry: Any
def invalidate(self): ...
def __init__(self, session_factory, scopefunc) -> None: ...
async def remove(self) -> None: ...
# proxied from Session

View File

@@ -3,7 +3,7 @@ from types import TracebackType
from typing import Any
from typing_extensions import Self
from ...util import memoized_property
from ...util.langhelpers import memoized_property
from .base import ReversibleProxy, StartableContext
class AsyncSession(ReversibleProxy):
@@ -55,6 +55,7 @@ class AsyncSession(ReversibleProxy):
async def rollback(self): ...
async def commit(self): ...
async def close(self): ...
async def invalidate(self): ...
@classmethod
async def close_all(cls): ...
async def __aenter__(self) -> Self: ...

View File

@@ -1,6 +1,8 @@
from _typeshed import Incomplete
from typing import Any
from ..orm.strategy_options import Load, loader_option
log: Any
class Bakery:
@@ -40,7 +42,8 @@ class Result:
def bake_lazy_loaders() -> None: ...
def unbake_lazy_loaders() -> None: ...
@loader_option()
def baked_lazyload(loadopt: Load, attr) -> loader_option: ...
def baked_lazyload_all(loadopt: Load, attr) -> loader_option: ...
baked_lazyload: Any
baked_lazyload_all: Any
bakery: Any
bakery = BakedQuery.bakery

View File

@@ -1,11 +1,23 @@
import sys
from _typeshed import Unused
from logging import Logger
from typing import Any, TypeVar, overload
from typing_extensions import Literal, Self, TypeAlias
from typing_extensions import Final, Literal, Self, TypeAlias
_ClsT = TypeVar("_ClsT", bound=type)
_EchoFlag: TypeAlias = bool | Literal["debug"] | None
if sys.version_info >= (3, 8):
STACKLEVEL: Final = True
if sys.version_info >= (3, 11):
STACKLEVEL_OFFSET: Final = 2
else:
STACKLEVEL_OFFSET: Final = 1
else:
STACKLEVEL: Final = False
STACKLEVEL_OFFSET: Final = 0
rootlogger: Any
def class_logger(cls: _ClsT) -> _ClsT: ...

View File

@@ -2,8 +2,34 @@ from _typeshed import Incomplete
from typing import Any, Generic, NamedTuple, TypeVar
from ..sql import base as sql_base, roles, traversals
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from . import interfaces
from .base import (
ATTR_EMPTY as ATTR_EMPTY,
ATTR_WAS_SET as ATTR_WAS_SET,
CALLABLES_OK as CALLABLES_OK,
DEFERRED_HISTORY_LOAD as DEFERRED_HISTORY_LOAD,
INIT_OK as INIT_OK,
LOAD_AGAINST_COMMITTED as LOAD_AGAINST_COMMITTED,
NEVER_SET as NEVER_SET,
NO_AUTOFLUSH as NO_AUTOFLUSH,
NO_CHANGE as NO_CHANGE,
NO_RAISE as NO_RAISE,
NO_VALUE as NO_VALUE,
NON_PERSISTENT_OK as NON_PERSISTENT_OK,
PASSIVE_CLASS_MISMATCH as PASSIVE_CLASS_MISMATCH,
PASSIVE_NO_FETCH as PASSIVE_NO_FETCH,
PASSIVE_NO_FETCH_RELATED as PASSIVE_NO_FETCH_RELATED,
PASSIVE_NO_INITIALIZE as PASSIVE_NO_INITIALIZE,
PASSIVE_NO_RESULT as PASSIVE_NO_RESULT,
PASSIVE_OFF as PASSIVE_OFF,
PASSIVE_ONLY_PERSISTENT as PASSIVE_ONLY_PERSISTENT,
PASSIVE_RETURN_NO_VALUE as PASSIVE_RETURN_NO_VALUE,
RELATED_OBJECT_OK as RELATED_OBJECT_OK,
SQL_OK as SQL_OK,
instance_dict as instance_dict,
instance_state as instance_state,
)
_T = TypeVar("_T")
@@ -27,6 +53,7 @@ class QueryableAttribute(
key: Any
impl: Any
comparator: Any
dispatch: Incomplete
def __init__(
self,
class_,

View File

@@ -1,6 +1,6 @@
from typing import Any
from ..util import memoized_property
from ..util.langhelpers import memoized_property
PASSIVE_NO_RESULT: Any
PASSIVE_CLASS_MISMATCH: Any
@@ -24,6 +24,7 @@ PASSIVE_NO_INITIALIZE: Any
PASSIVE_NO_FETCH: Any
PASSIVE_NO_FETCH_RELATED: Any
PASSIVE_ONLY_PERSISTENT: Any
PASSIVE_MERGE: Any
DEFAULT_MANAGER_ATTR: str
DEFAULT_STATE_ATTR: str
EXT_CONTINUE: Any

View File

@@ -56,6 +56,7 @@ class ORMCompileState(CompileState):
class ORMFromStatementCompileState(ORMCompileState):
multi_row_eager_loaders: bool
eager_adding_joins: bool
compound_eager_adapter: Any
extra_criteria_entities: Any
eager_joins: Any
@@ -78,6 +79,7 @@ class ORMFromStatementCompileState(ORMCompileState):
class ORMSelectCompileState(ORMCompileState, SelectState):
multi_row_eager_loaders: bool
eager_adding_joins: bool
compound_eager_adapter: Any
correlate: Any
correlate_except: Any

View File

@@ -5,7 +5,7 @@ from typing_extensions import TypeAlias
from ..engine.interfaces import Connectable
from ..sql.schema import MetaData
from ..util import hybridproperty
from ..util.langhelpers import hybridproperty
from . import interfaces
_ClsT = TypeVar("_ClsT", bound=type[Any])

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing import Any, ClassVar, Generic, TypeVar
from ..sql.operators import ColumnOperators
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from . import util as orm_util
from .interfaces import MapperProperty, PropComparator

View File

@@ -1,11 +1,13 @@
from _typeshed import Incomplete
from typing import Any
from ..util import HasMemoized, hybridmethod
from ..util.langhelpers import HasMemoized, hybridmethod
from . import base
DEL_ATTR: Any
instrumentation_finders: Any
class ClassManager(HasMemoized, dict[Any, Any]):
MANAGER_ATTR: Any
STATE_ATTR: Any
@@ -24,6 +26,7 @@ class ClassManager(HasMemoized, dict[Any, Any]):
new_init: Any
local_attrs: Any
originals: Any
dispatch: Incomplete
def __init__(self, class_) -> None: ...
def __hash__(self) -> int: ... # type: ignore[override]
def __eq__(self, other): ...
@@ -67,6 +70,7 @@ class _SerializeManager:
def __call__(self, state, inst, state_dict) -> None: ...
class InstrumentationFactory:
dispatch: Incomplete
def create_manager_for_cls(self, class_): ...
def unregister(self, class_) -> None: ...

View File

@@ -44,6 +44,8 @@ class ORMFromClauseRole(roles.StrictFromClauseRole): ...
class MapperProperty(HasCacheKey, _MappedAttribute, InspectionAttr, util.MemoizedSlots):
cascade: Any
is_property: bool
key: Incomplete
info: Incomplete
def setup(self, context, query_entity, path, adapter, **kwargs) -> None: ...
def create_row_processor(self, context, query_entity, path, mapper, result, adapter, populators) -> None: ...
def cascade_iterator(self, type_, state, dict_, visited_states, halt_on: Incomplete | None = None): ...

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing import Any
from ..sql import base as sql_base
from ..util import HasMemoized, memoized_property
from ..util.langhelpers import HasMemoized, memoized_property
from .base import (
_class_to_mapper as _class_to_mapper,
_state_mapper as _state_mapper,
@@ -43,6 +43,7 @@ class Mapper(ORMFromClauseRole, ORMEntityColumnsClauseRole, sql_base.MemoizedHas
polymorphic_map: Any
include_properties: Any
exclude_properties: Any
dispatch: Incomplete
def __init__(
self,
class_,

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing import Any, ClassVar
from ..sql.traversals import HasCacheKey
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from . import base as orm_base
log: Any

View File

@@ -1,7 +1,7 @@
from typing import Any
from ..sql.base import CompileState, Options
from ..sql.dml import DeleteDMLState, UpdateDMLState
from ..sql.dml import DeleteDMLState, InsertDMLState, UpdateDMLState
def save_obj(base_mapper, states, uowtransaction, single: bool = False) -> None: ...
def post_update(base_mapper, states, uowtransaction, post_update_cols) -> None: ...
@@ -15,6 +15,18 @@ class BulkUDCompileState(CompileState):
@classmethod
def orm_setup_cursor_result(cls, session, statement, params, execution_options, bind_arguments, result): ...
class ORMDMLState:
@classmethod
def get_entity_description(cls, statement): ...
@classmethod
def get_returning_column_descriptions(cls, statement): ...
class ORMInsert(ORMDMLState, InsertDMLState):
@classmethod
def orm_pre_session_exec(cls, session, statement, params, execution_options, bind_arguments, is_reentrant_invoke): ...
@classmethod
def orm_setup_cursor_result(cls, session, statement, params, execution_options, bind_arguments, result): ...
class BulkORMUpdate(UpdateDMLState, BulkUDCompileState):
mapper: Any
extra_criteria_entities: Any

View File

@@ -19,6 +19,7 @@ class Query(_SelectFromElements, SupportsCloneAnnotations, HasPrefixes, HasSuffi
logger: Any
load_options: Any
session: Any
dispatch: Incomplete
def __init__(self, entities, session: Incomplete | None = None) -> None: ...
@property
def statement(self): ...

View File

@@ -2,7 +2,7 @@ from _typeshed import Incomplete
from typing import Any, ClassVar, Generic, TypeVar
from ..sql.operators import ColumnOperators
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from .interfaces import PropComparator, StrategizedProperty
_T = TypeVar("_T")

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from ..util import memoized_property
from ..util.langhelpers import memoized_property
class ScopedSessionMixin:
def __call__(self, **kw): ...

View File

@@ -9,7 +9,7 @@ from ..engine.result import Result
from ..engine.util import TransactionalContext
from ..sql.elements import ColumnElement
from ..sql.schema import Table
from ..util import MemoizedSlots, memoized_property
from ..util.langhelpers import MemoizedSlots, memoized_property
from .query import Query
_T = TypeVar("_T")
@@ -93,6 +93,7 @@ class Session(_SessionClassMethods):
enable_baked_queries: Any
autocommit: bool
twophase: Any
dispatch: Incomplete
def __init__(
self,
bind: Incomplete | None = None,

View File

@@ -1,6 +1,6 @@
from typing import Any
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from . import interfaces
class InstanceState(interfaces.InspectionAttrInfo):

View File

@@ -40,6 +40,7 @@ class Load(Generative, LoaderOption):
def undefer_group(loadopt, name) -> Self: ...
def with_expression(loadopt, key, expression) -> Self: ...
def selectin_polymorphic(loadopt, classes) -> Self: ...
def baked_lazyload(loadopt, attr) -> Self: ...
class _UnboundLoad(Load):
path: Any

View File

@@ -4,7 +4,7 @@ from collections.abc import Callable
from typing import Any
from .. import log
from ..util import memoized_property
from ..util.langhelpers import memoized_property
reset_rollback: Any
reset_commit: Any
@@ -12,8 +12,10 @@ reset_none: Any
class _ConnDialect:
is_async: bool
has_terminate: bool
def do_rollback(self, dbapi_connection) -> None: ...
def do_commit(self, dbapi_connection) -> None: ...
def do_terminate(self, dbapi_connection) -> None: ...
def do_close(self, dbapi_connection) -> None: ...
def do_ping(self, dbapi_connection) -> None: ...
def get_driver_connection(self, connection): ...
@@ -24,6 +26,7 @@ class _AsyncConnDialect(_ConnDialect):
class Pool(log.Identified):
logging_name: Any
echo: Any
dispatch: Incomplete
def __init__(
self,
creator: Callable[[], DBAPIConnection],

View File

@@ -1,6 +1,6 @@
from typing import Any
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from .base import Pool
class QueuePool(Pool):

View File

@@ -1,13 +1,112 @@
from typing import Any
from _typeshed import Incomplete
from typing import TypeVar
EMPTY_ANNOTATIONS: Any
from ..schema import Table
from ..util import immutabledict
from .compiler import _CompileLabel
from .crud import _multiparam_column
from .elements import (
AnnotatedColumnElement as _ElementsAnnotatedColumnElement,
AsBoolean,
BinaryExpression,
BindParameter,
BooleanClauseList,
Case,
Cast,
ClauseList,
CollationClause,
CollectionAggregate,
ColumnClause,
ColumnElement,
Extract,
False_,
FunctionFilter,
Grouping,
IndexExpression,
Label,
NamedColumn,
Null,
Over,
Slice,
TableValuedColumn,
True_,
Tuple,
TypeCoerce,
UnaryExpression,
WithinGroup,
_label_reference,
_textual_label_reference,
)
from .functions import (
AnsiFunction,
Function,
FunctionAsBinary,
FunctionElement,
GenericFunction,
OrderedSetAgg,
ReturnTypeFromArgs,
ScalarFunctionColumn,
array_agg,
char_length,
coalesce,
concat,
count,
cube,
cume_dist,
current_date,
current_time,
current_timestamp,
current_user,
dense_rank,
grouping_sets,
localtime,
localtimestamp,
max,
min,
mode,
next_value,
now,
percent_rank,
percentile_cont,
percentile_disc,
random,
rank,
rollup,
session_user,
sum,
sysdate,
user,
)
from .schema import Column
from .selectable import (
CTE,
Alias,
AliasedReturnsRows,
AnnotatedFromClause as _SelectableAnnotatedFromClause,
Exists,
FromClause,
FromGrouping,
Join,
Lateral,
ScalarSelect,
Subquery,
TableClause,
TableSample,
TableValuedAlias,
Values,
_OffsetLimitParam,
)
_T = TypeVar("_T")
EMPTY_ANNOTATIONS: immutabledict[Incomplete, Incomplete]
class SupportsAnnotations: ...
class SupportsCloneAnnotations(SupportsAnnotations): ...
class SupportsWrappingAnnotations(SupportsAnnotations): ...
class Annotated:
__dict__: Any
__dict__: dict[str, Incomplete]
def __init__(self, element, values) -> None: ...
def __reduce__(self): ...
def __hash__(self) -> int: ...
@@ -15,4 +114,93 @@ class Annotated:
@property
def entity_namespace(self): ...
annotated_classes: Any
annotated_classes: dict[Incomplete, Incomplete]
# Everything below is dynamically generated at runtime
class AnnotatedAlias(AnnotatedAliasedReturnsRows, Alias): ...
class AnnotatedAliasedReturnsRows(AnnotatedFromClause, AliasedReturnsRows): ...
class AnnotatedAnsiFunction(AnnotatedGenericFunction[_T], AnsiFunction): ... # type: ignore[misc]
class AnnotatedAsBoolean(AnnotatedUnaryExpression[_T], AsBoolean): ...
class AnnotatedBinaryExpression(AnnotatedColumnElement[_T], BinaryExpression): ...
class AnnotatedBindParameter(AnnotatedColumnElement[_T], BindParameter[_T]): ...
class AnnotatedBooleanClauseList(AnnotatedColumnElement[_T], BooleanClauseList): ...
class AnnotatedCTE(AnnotatedAliasedReturnsRows, CTE): ...
class AnnotatedCase(AnnotatedColumnElement[_T], Case): ...
class AnnotatedCast(AnnotatedColumnElement[_T], Cast): ...
class AnnotatedClauseList(Annotated, ClauseList): ...
class AnnotatedCollationClause(AnnotatedColumnElement[_T], CollationClause): ...
class AnnotatedCollectionAggregate(AnnotatedUnaryExpression[_T], CollectionAggregate): ...
class AnnotatedColumn(AnnotatedColumnClause[_T], Column): ...
class AnnotatedColumnClause(AnnotatedNamedColumn[_T], ColumnClause): ...
class AnnotatedColumnElement(_ElementsAnnotatedColumnElement, ColumnElement[_T]): ...
class AnnotatedExists(AnnotatedUnaryExpression[_T], Exists): ...
class AnnotatedExtract(AnnotatedColumnElement[_T], Extract): ...
class AnnotatedFalse_(AnnotatedColumnElement[_T], False_): ...
class AnnotatedFromClause(_SelectableAnnotatedFromClause, FromClause): ...
class AnnotatedFromGrouping(AnnotatedFromClause, FromGrouping): ...
class AnnotatedFunction(AnnotatedFunctionElement[_T], Function): ... # type: ignore[misc]
class AnnotatedFunctionAsBinary(AnnotatedBinaryExpression[_T], FunctionAsBinary): ...
class AnnotatedFunctionElement(AnnotatedColumnElement[_T], FunctionElement): ... # type: ignore[misc]
class AnnotatedFunctionFilter(AnnotatedColumnElement[_T], FunctionFilter): ...
class AnnotatedGenericFunction(AnnotatedFunction[_T], GenericFunction): ... # type: ignore[misc]
class AnnotatedGrouping(AnnotatedColumnElement[_T], Grouping): ...
class AnnotatedIndexExpression(AnnotatedBinaryExpression[_T], IndexExpression): ...
class AnnotatedJoin(AnnotatedFromClause, Join): ...
class AnnotatedLabel(AnnotatedColumnElement[_T], Label): ...
class AnnotatedLateral(AnnotatedAliasedReturnsRows, Lateral): ...
class AnnotatedNamedColumn(AnnotatedColumnElement[_T], NamedColumn): ...
class AnnotatedNull(AnnotatedColumnElement[_T], Null): ...
class AnnotatedOrderedSetAgg(AnnotatedGenericFunction[_T], OrderedSetAgg): ... # type: ignore[misc]
class AnnotatedOver(AnnotatedColumnElement[_T], Over): ...
class AnnotatedReturnTypeFromArgs(AnnotatedGenericFunction[_T], ReturnTypeFromArgs): ... # type: ignore[misc]
class AnnotatedScalarFunctionColumn(AnnotatedNamedColumn[_T], ScalarFunctionColumn): ...
class AnnotatedScalarSelect(AnnotatedGrouping[_T], ScalarSelect): ...
class AnnotatedSlice(AnnotatedColumnElement[_T], Slice): ...
class AnnotatedSubquery(AnnotatedAliasedReturnsRows, Subquery): ...
class AnnotatedTable(AnnotatedTableClause, Table): ...
class AnnotatedTableClause(AnnotatedFromClause, TableClause): ...
class AnnotatedTableSample(AnnotatedAliasedReturnsRows, TableSample): ...
class AnnotatedTableValuedAlias(AnnotatedAlias, TableValuedAlias): ...
class AnnotatedTableValuedColumn(AnnotatedNamedColumn[_T], TableValuedColumn): ...
class AnnotatedTrue_(AnnotatedColumnElement[_T], True_): ...
class AnnotatedTuple(AnnotatedColumnElement[_T], Tuple): ...
class AnnotatedTypeCoerce(AnnotatedColumnElement[_T], TypeCoerce): ...
class AnnotatedUnaryExpression(AnnotatedColumnElement[_T], UnaryExpression): ...
class AnnotatedValues(AnnotatedFromClause, Values): ...
class AnnotatedWithinGroup(AnnotatedColumnElement[_T], WithinGroup): ...
class Annotated_CompileLabel(AnnotatedColumnElement[_T], _CompileLabel): ...
class Annotated_OffsetLimitParam(AnnotatedBindParameter[_T], _OffsetLimitParam): ...
class Annotated_label_reference(AnnotatedColumnElement[_T], _label_reference): ...
class Annotated_multiparam_column(AnnotatedColumnElement[_T], _multiparam_column[_T]): ...
class Annotated_textual_label_reference(AnnotatedColumnElement[_T], _textual_label_reference): ...
class Annotatedarray_agg(AnnotatedGenericFunction[_T], array_agg): ... # type: ignore[misc]
class Annotatedchar_length(AnnotatedGenericFunction[_T], char_length): ... # type: ignore[misc]
class Annotatedcoalesce(AnnotatedReturnTypeFromArgs[_T], coalesce): ... # type: ignore[misc]
class Annotatedconcat(AnnotatedGenericFunction[_T], concat): ... # type: ignore[misc]
class Annotatedcount(AnnotatedGenericFunction[_T], count): ... # type: ignore[misc]
class Annotatedcube(AnnotatedGenericFunction[_T], cube): ... # type: ignore[misc]
class Annotatedcume_dist(AnnotatedGenericFunction[_T], cume_dist): ... # type: ignore[misc]
class Annotatedcurrent_date(AnnotatedAnsiFunction[_T], current_date): ... # type: ignore[misc]
class Annotatedcurrent_time(AnnotatedAnsiFunction[_T], current_time): ... # type: ignore[misc]
class Annotatedcurrent_timestamp(AnnotatedAnsiFunction[_T], current_timestamp): ... # type: ignore[misc]
class Annotatedcurrent_user(AnnotatedAnsiFunction[_T], current_user): ... # type: ignore[misc]
class Annotateddense_rank(AnnotatedGenericFunction[_T], dense_rank): ... # type: ignore[misc]
class Annotatedgrouping_sets(AnnotatedGenericFunction[_T], grouping_sets): ... # type: ignore[misc]
class Annotatedlocaltime(AnnotatedAnsiFunction[_T], localtime): ... # type: ignore[misc]
class Annotatedlocaltimestamp(AnnotatedAnsiFunction[_T], localtimestamp): ... # type: ignore[misc]
class Annotatedmax(AnnotatedReturnTypeFromArgs[_T], max): ... # type: ignore[misc]
class Annotatedmin(AnnotatedReturnTypeFromArgs[_T], min): ... # type: ignore[misc]
class Annotatedmode(AnnotatedOrderedSetAgg[_T], mode): ... # type: ignore[misc]
class Annotatednext_value(AnnotatedGenericFunction[_T], next_value): ... # type: ignore[misc]
class Annotatednow(AnnotatedGenericFunction[_T], now): ... # type: ignore[misc]
class Annotatedpercent_rank(AnnotatedGenericFunction[_T], percent_rank): ... # type: ignore[misc]
class Annotatedpercentile_cont(AnnotatedOrderedSetAgg[_T], percentile_cont): ... # type: ignore[misc]
class Annotatedpercentile_disc(AnnotatedOrderedSetAgg[_T], percentile_disc): ... # type: ignore[misc]
class Annotatedrandom(AnnotatedGenericFunction[_T], random): ... # type: ignore[misc]
class Annotatedrank(AnnotatedGenericFunction[_T], rank): ... # type: ignore[misc]
class Annotatedrollup(AnnotatedGenericFunction[_T], rollup): ... # type: ignore[misc]
class Annotatedsession_user(AnnotatedAnsiFunction[_T], session_user): ... # type: ignore[misc]
class Annotatedsum(AnnotatedReturnTypeFromArgs[_T], sum): ... # type: ignore[misc]
class Annotatedsysdate(AnnotatedAnsiFunction[_T], sysdate): ... # type: ignore[misc]
class Annotateduser(AnnotatedAnsiFunction[_T], user): ... # type: ignore[misc]

View File

@@ -4,7 +4,7 @@ from typing import Any, ClassVar
from typing_extensions import Self
from .. import util
from ..util import HasMemoized, hybridmethod, memoized_property
from ..util.langhelpers import HasMemoized, hybridmethod, memoized_property
from . import roles
from .elements import ColumnElement
from .traversals import (
@@ -110,7 +110,8 @@ class Executable(roles.StatementRole, Generative):
class prefix_anon_map(dict[Any, Any]):
def __missing__(self, key): ...
class SchemaEventTarget: ...
class SchemaEventTarget:
dispatch: Incomplete
class SchemaVisitor(ClauseVisitor):
__traverse_options__: Any

View File

@@ -1,10 +1,9 @@
from _typeshed import Incomplete
from typing import NamedTuple
from sqlalchemy.util.langhelpers import EnsureKWArgType
from ..util import memoized_property
from . import elements
from ..util import EnsureKWArgType, memoized_property
from .base import CompileState
from .elements import ColumnElement
RESERVED_WORDS: Incomplete
LEGAL_CHARACTERS: Incomplete
@@ -45,6 +44,7 @@ class Compiled:
schema_translate_map: Incomplete
execution_options: Incomplete
compile_state: Incomplete
dml_compile_state: CompileState | None
cache_key: Incomplete
dialect: Incomplete
preparer: Incomplete
@@ -76,7 +76,7 @@ class TypeCompiler(metaclass=EnsureKWArgType):
def process(self, type_, **kw): ...
def visit_unsupported_compilation(self, element, err, **kw) -> None: ...
class _CompileLabel(elements.ColumnElement[Incomplete]):
class _CompileLabel(ColumnElement[Incomplete]):
__visit_name__: str
element: Incomplete
name: Incomplete
@@ -107,6 +107,7 @@ class SQLCompiler(Compiled):
update_prefetch: Incomplete
postfetch_lastrowid: bool
positiontup: Incomplete
positiontup_level: dict[str, int] | None
inline: bool
column_keys: Incomplete
cache_key: Incomplete

View File

@@ -13,6 +13,10 @@ class DMLState(CompileState):
def __init__(self, statement, compiler, **kw) -> None: ...
@property
def dml_table(self): ...
@classmethod
def get_entity_description(cls, statement) -> dict[str, Incomplete]: ...
@classmethod
def get_returning_column_descriptions(cls, statement) -> list[dict[str, Incomplete]]: ...
class InsertDMLState(DMLState):
isinsert: bool
@@ -43,6 +47,10 @@ class UpdateBase(roles.DMLRole, HasCTE, HasCompileState, DialectKWArgs, HasPrefi
@property
def exported_columns(self): ...
def with_hint(self, text, selectable: Incomplete | None = None, dialect_name: str = "*") -> None: ...
@property
def entity_description(self): ...
@property
def returning_column_descriptions(self): ...
class ValuesBase(UpdateBase):
__visit_name__: str

View File

@@ -3,7 +3,7 @@ from typing import Any, Generic, TypeVar
from typing_extensions import Literal, Self
from .. import util
from ..util import HasMemoized, memoized_property
from ..util.langhelpers import HasMemoized, memoized_property
from . import operators, roles
from .annotation import Annotated, SupportsWrappingAnnotations
from .base import Executable, Immutable, SingletonConstant
@@ -449,13 +449,13 @@ class quoted_name(util.MemoizedSlots, util.text_type):
class AnnotatedColumnElement(Annotated):
def __init__(self, element, values) -> None: ...
@memoized_property
@property # Should be @memoized_property, but that causes issues with regr_test
def name(self): ...
@memoized_property
@property # Should be @memoized_property, but that causes issues with regr_test
def table(self): ...
@memoized_property
@property # Should be @memoized_property, but that causes issues with regr_test
def key(self): ...
@memoized_property
@property # Should be @memoized_property, but that causes issues with regr_test
def info(self): ...
class _truncated_label(quoted_name):

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from ..util import HasMemoized
from ..util.langhelpers import HasMemoized
from .base import Executable, Generative
from .elements import BinaryExpression, ColumnElement, NamedColumn
from .selectable import FromClause, TableValuedAlias

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete
from typing import Any
from ..util import memoized_property
from ..util.langhelpers import memoized_property
from . import visitors
from .base import DialectKWArgs, Executable, SchemaEventTarget
from .elements import ColumnClause
@@ -14,7 +14,7 @@ NULL_UNSPECIFIED: Any
class SchemaItem(SchemaEventTarget, visitors.Visitable):
__visit_name__: str
create_drop_stringify_dialect: str
@memoized_property
@property # Should be @memoized_property, but that causes issues with regr_test
def info(self): ...
class Table(DialectKWArgs, SchemaItem, TableClause):

View File

@@ -3,7 +3,7 @@ from typing import Any
from typing_extensions import Self
from .. import util
from ..util import HasMemoized, memoized_property
from ..util.langhelpers import HasMemoized, memoized_property
from . import roles, traversals, visitors
from .annotation import Annotated, SupportsCloneAnnotations
from .base import CacheableOptions, CompileState, Executable, Generative, HasCompileState, Immutable
@@ -116,6 +116,14 @@ class Alias(roles.DMLTableRole, AliasedReturnsRows):
class TableValuedAlias(Alias):
__visit_name__: str
joins_implicitly: bool
def _init(
self,
selectable,
name: Incomplete | None = None,
table_value_type: Incomplete | None = None,
joins_implicitly: bool = False,
) -> None: ...
@HasMemoized.memoized_attribute
def column(self): ...
def alias(self, name: Incomplete | None = None): ... # type: ignore[override]

View File

@@ -370,9 +370,12 @@ class TableValueType(HasCacheKey, TypeEngine):
class MatchType(Boolean): ...
NULLTYPE: Any
BOOLEANTYPE: Any
STRINGTYPE: Any
INTEGERTYPE: Any
MATCHTYPE: Any
TABLEVALUE: Any
NULLTYPE: NullType
BOOLEANTYPE: Boolean
STRINGTYPE: String
INTEGERTYPE: Integer
NUMERICTYPE: Numeric
MATCHTYPE: MatchType
TABLEVALUE: TableValueType
DATETIME_TIMEZONE: DateTime
TIME_TIMEZONE: Time

View File

@@ -1,7 +1,6 @@
from typing import Any
from .. import util
from ..util import HasMemoized
from ..util.langhelpers import HasMemoized, MemoizedSlots
from .visitors import ExtendedInternalTraversal, InternalTraversal
SKIP_TRAVERSE: Any
@@ -106,7 +105,7 @@ class anon_map(dict[Any, Any]):
def __init__(self) -> None: ...
def __missing__(self, key): ...
class TraversalComparatorStrategy(InternalTraversal, util.MemoizedSlots):
class TraversalComparatorStrategy(InternalTraversal, MemoizedSlots):
stack: Any
cache: Any
anon_map: Any

View File

@@ -4,6 +4,7 @@ from typing import Any, Generic, TypeVar
from .. import util
from . import operators
from .base import SchemaEventTarget
from .sqltypes import Boolean
from .visitors import Traversible, TraversibleType
_T = TypeVar("_T")
@@ -11,6 +12,7 @@ _T = TypeVar("_T")
BOOLEANTYPE: Any
INTEGERTYPE: Any
NULLTYPE: Any
NUMERICTYPE: Any
STRINGTYPE: Any
MATCHTYPE: Any
INDEXABLE: Any
@@ -26,6 +28,7 @@ class TypeEngine(Traversible):
def operate(self, op, *other, **kwargs): ...
def reverse_operate(self, op, other, **kwargs): ...
def __reduce__(self): ...
BOOLEANTYPE: Boolean
hashable: bool
comparator_factory: Any
sort_key_function: Any

View File

@@ -39,6 +39,7 @@ from .config import (
combinations_list as combinations_list,
db as db,
fixture as fixture,
requirements,
)
from .exclusions import (
db_spec as db_spec,
@@ -69,6 +70,8 @@ from .util import (
)
from .warnings import assert_warnings as assert_warnings, warn_test_suite as warn_test_suite
requires = requirements
def against(*queries): ...
crashes = skip

View File

@@ -8,6 +8,7 @@ def expect_deprecated_20(*messages, **kw): ...
def emits_warning_on(db, *messages): ...
def uses_deprecated(*messages): ...
def global_cleanup_assertions() -> None: ...
def int_within_variance(expected, received, variance) -> None: ...
def eq_regex(a, b, msg: Incomplete | None = None) -> None: ...
def eq_(a, b, msg: Incomplete | None = None) -> None: ...
def ne_(a, b, msg: Incomplete | None = None) -> None: ...
@@ -32,6 +33,8 @@ def eq_ignore_whitespace(a, b, msg: Incomplete | None = None) -> None: ...
def assert_raises(except_cls, callable_, *args, **kw): ...
def assert_raises_context_ok(except_cls, callable_, *args, **kw): ...
def assert_raises_message(except_cls, msg, callable_, *args, **kwargs): ...
def assert_warns(except_cls, callable_, *args, **kwargs): ...
def assert_warns_message(except_cls, msg, callable_, *args, **kwargs): ...
def assert_raises_message_context_ok(except_cls, msg, callable_, *args, **kwargs): ...
class _ErrorContainer:

View File

@@ -13,6 +13,7 @@ ident: str
def combinations(*comb, **kw): ...
def combinations_list(arg_iterable, **kw): ...
def variation(argname, cases): ...
def fixture(*arg, **kw): ...
def get_current_test_name(): ...
def mark_base_test_class(): ...

View File

@@ -0,0 +1 @@
from unittest.mock import ANY as ANY, MagicMock as MagicMock, Mock as Mock, call as call, patch as patch

View File

@@ -1,10 +1,9 @@
import abc
from abc import ABC as ABC, ABCMeta, abstractmethod
from typing import Any
bootstrapped_as_sqlalchemy: bool
log: Any
py3k: Any
ABC = abc.ABC
fixtures: Any
engines: Any
@@ -47,17 +46,17 @@ def before_test(test, test_module_name, test_class, test_name) -> None: ...
def after_test(test) -> None: ...
def after_test_fixtures(test) -> None: ...
class FixtureFunctions(ABC, metaclass=abc.ABCMeta):
@abc.abstractmethod
class FixtureFunctions(ABC, metaclass=ABCMeta):
@abstractmethod
def skip_test_exception(self, *arg, **kw): ...
@abc.abstractmethod
@abstractmethod
def combinations(self, *args, **kw): ...
@abc.abstractmethod
@abstractmethod
def param_ident(self, *args, **kw): ...
@abc.abstractmethod
@abstractmethod
def fixture(self, *arg, **kw): ...
def get_current_test_name(self) -> None: ...
@abc.abstractmethod
@abstractmethod
def mark_base_test_class(self): ...
def set_fixture_functions(fixture_fn_class) -> None: ...

View File

@@ -13,6 +13,11 @@ def collect_types_fixture() -> None: ...
def pytest_sessionstart(session) -> None: ...
def pytest_sessionfinish(session) -> None: ...
def pytest_collection_finish(session): ...
class XDistHooks:
def pytest_configure_node(self, node) -> None: ...
def pytest_testnodedown(self, node, error) -> None: ...
def pytest_collection_modifyitems(session, config, items): ...
def pytest_pycollect_makeitem(collector, name, obj): ...
def pytest_runtest_setup(item) -> None: ...

View File

@@ -1,14 +1,13 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, Unused
from collections.abc import Callable
from logging import Logger
from typing import Any, Generic, NoReturn, TypeVar
from typing_extensions import Self, TypeAlias
from typing_extensions import Self
from ..engine.interfaces import Connectable
from ..engine.url import URL
from .config import Config, _ConfigProtocol
_Unused: TypeAlias = object
_S = TypeVar("_S", bound=str)
_U = TypeVar("_U", bound=URL)
_F = TypeVar("_F", bound=Callable[..., str | URL | None])
@@ -34,30 +33,30 @@ class register(Generic[_F]):
@register.init
def generate_driver_url(url: _U, driver: str, query_str: str) -> _U | None: ...
@register.init
def drop_all_schema_objects_pre_tables(cfg: _Unused, eng: _Unused) -> None: ...
def drop_all_schema_objects_pre_tables(cfg: Unused, eng: Unused) -> None: ...
@register.init
def drop_all_schema_objects_post_tables(cfg: _Unused, eng: _Unused) -> None: ...
def drop_all_schema_objects_post_tables(cfg: Unused, eng: Unused) -> None: ...
@register.init
def create_db(cfg: _Unused, eng: Connectable, ident: _Unused) -> NoReturn: ...
def create_db(cfg: Unused, eng: Connectable, ident: Unused) -> NoReturn: ...
@register.init
def drop_db(cfg: _Unused, eng: Connectable, ident: _Unused) -> NoReturn: ...
def drop_db(cfg: Unused, eng: Connectable, ident: Unused) -> NoReturn: ...
@register.init
def update_db_opts(db_url: _Unused, db_opts: _Unused) -> None: ...
def update_db_opts(db_url: Unused, db_opts: Unused) -> None: ...
@register.init
def post_configure_engine(url: _Unused, engine: _Unused, follower_ident: _Unused) -> None: ...
def post_configure_engine(url: Unused, engine: Unused, follower_ident: Unused) -> None: ...
@register.init
def follower_url_from_main(url: _U, ident: str) -> _U: ...
@register.init
def configure_follower(cfg: _Unused, ident: _Unused) -> None: ...
def configure_follower(cfg: Unused, ident: Unused) -> None: ...
@register.init
def run_reap_dbs(url: _Unused, ident: _Unused) -> None: ...
def run_reap_dbs(url: Unused, ident: Unused) -> None: ...
@register.init
def temp_table_keyword_args(cfg: _Unused, eng: Connectable) -> NoReturn: ...
def temp_table_keyword_args(cfg: Unused, eng: Connectable) -> NoReturn: ...
@register.init
def prepare_for_drop_tables(config: _Unused, connection: _Unused) -> None: ...
def prepare_for_drop_tables(config: Unused, connection: Unused) -> None: ...
@register.init
def stop_test_class_outside_fixtures(config: _Unused, db: _Unused, testcls: _Unused) -> None: ...
def stop_test_class_outside_fixtures(config: Unused, db: Unused, testcls: Unused) -> None: ...
@register.init # type: ignore[type-var] # False-positive, _S is bound to str
def get_temp_table_name(cfg: _Unused, eng: _Unused, base_name: _S) -> _S: ...
def get_temp_table_name(cfg: Unused, eng: Unused, base_name: _S) -> _S: ...
@register.init
def set_default_schema_on_connection(cfg: _ConfigProtocol, dbapi_connection: _Unused, schema_name: _Unused) -> NoReturn: ...
def set_default_schema_on_connection(cfg: _ConfigProtocol, dbapi_connection: Unused, schema_name: Unused) -> NoReturn: ...

View File

@@ -1,3 +1,5 @@
from ..testing.exclusions import compound
class Requirements: ...
class SuiteRequirements(Requirements):
@@ -34,6 +36,8 @@ class SuiteRequirements(Requirements):
@property
def implicitly_named_constraints(self): ...
@property
def unusual_column_name_characters(self) -> compound: ...
@property
def subqueries(self): ...
@property
def offset(self): ...
@@ -168,6 +172,8 @@ class SuiteRequirements(Requirements):
@property
def temp_table_names(self): ...
@property
def has_temp_table(self) -> compound: ...
@property
def temporary_tables(self): ...
@property
def temporary_views(self): ...
@@ -198,10 +204,18 @@ class SuiteRequirements(Requirements):
@property
def datetime(self): ...
@property
def datetime_timezone(self) -> compound: ...
@property
def time_timezone(self) -> compound: ...
@property
def datetime_implicit_bound(self) -> compound: ...
@property
def datetime_microseconds(self): ...
@property
def timestamp_microseconds(self): ...
@property
def timestamp_microseconds_implicit_bound(self) -> compound: ...
@property
def datetime_historic(self): ...
@property
def date(self): ...
@@ -326,6 +340,8 @@ class SuiteRequirements(Requirements):
@property
def cpython(self): ...
@property
def is64bit(self) -> compound: ...
@property
def patch_library(self): ...
@property
def non_broken_pickle(self): ...
@@ -340,6 +356,8 @@ class SuiteRequirements(Requirements):
@property
def async_dialect(self): ...
@property
def asyncio(self) -> compound: ...
@property
def greenlet(self): ...
@property
def computed_columns(self): ...

View File

@@ -36,4 +36,6 @@ class adict(dict[Any, Any]):
def drop_all_tables_from_metadata(metadata, engine_or_connection) -> None: ...
def drop_all_tables(engine, inspector, schema: Incomplete | None = None, include_names: Incomplete | None = None) -> None: ...
def total_size(o) -> int: ...
def teardown_events(event_cls): ...
def count_cache_key_tuples(tup) -> int: ...

View File

@@ -1,6 +1,16 @@
from collections import defaultdict as defaultdict
import asyncio as asyncio
import pickle as pickle
import threading as threading
from abc import ABC as ABC
from builtins import callable as callable, next as next
from collections import defaultdict as defaultdict, namedtuple as namedtuple # noqa: Y024 # Actual import
from contextlib import contextmanager as contextmanager
from functools import partial as partial, update_wrapper as update_wrapper
from datetime import timezone as timezone
from functools import partial as partial, reduce as reduce, update_wrapper as update_wrapper
from io import StringIO as StringIO
from itertools import zip_longest as zip_longest
from typing import TYPE_CHECKING as TYPE_CHECKING
from urllib.parse import parse_qsl as parse_qsl, quote_plus as quote_plus, unquote as unquote, unquote_plus as unquote_plus
from ._collections import (
EMPTY_DICT as EMPTY_DICT,
@@ -40,9 +50,6 @@ from ._collections import (
)
from ._preloaded import preload_module as preload_module, preloaded as preloaded
from .compat import (
ABC as ABC,
TYPE_CHECKING as TYPE_CHECKING,
StringIO as StringIO,
arm as arm,
b as b,
b64decode as b64decode,
@@ -50,7 +57,6 @@ from .compat import (
binary_type as binary_type,
binary_types as binary_types,
byte_buffer as byte_buffer,
callable as callable,
cmp as cmp,
cpython as cpython,
dataclass_fields as dataclass_fields,
@@ -64,13 +70,9 @@ from .compat import (
itertools_filter as itertools_filter,
itertools_filterfalse as itertools_filterfalse,
local_dataclass_fields as local_dataclass_fields,
namedtuple as namedtuple,
next as next,
nullcontext as nullcontext,
osx as osx,
parse_qsl as parse_qsl,
perf_counter as perf_counter,
pickle as pickle,
print_ as print_,
py2k as py2k,
py3k as py3k,
@@ -81,25 +83,18 @@ from .compat import (
py311 as py311,
py312 as py312,
pypy as pypy,
quote_plus as quote_plus,
quote as quote,
raise_ as raise_,
raise_from_cause as raise_from_cause,
reduce as reduce,
reraise as reraise,
string_types as string_types,
text_type as text_type,
threading as threading,
timezone as timezone,
u as u,
ue as ue,
unquote as unquote,
unquote_plus as unquote_plus,
win32 as win32,
with_metaclass as with_metaclass,
zip_longest as zip_longest,
)
from .concurrency import (
asyncio as asyncio,
await_fallback as await_fallback,
await_only as await_only,
greenlet_spawn as greenlet_spawn,

View File

@@ -88,11 +88,11 @@ class OrderedSet(set[_T], Generic[_T]):
def union(self, other: Iterable[_S]) -> OrderedSet[_S | _T]: ... # type: ignore[override]
__or__ = union # type: ignore[assignment] # pyright: ignore[reportGeneralTypeIssues]
def intersection(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__and__ = intersection
__and__ = intersection # type: ignore[assignment]
def symmetric_difference(self, other: Iterable[_S]) -> OrderedSet[_S | _T]: ...
__xor__ = symmetric_difference # type: ignore[assignment] # pyright: ignore[reportGeneralTypeIssues]
def difference(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__sub__ = difference
__sub__ = difference # type: ignore[assignment]
def intersection_update(self, other: Iterable[Any]) -> Self: ... # type: ignore[override]
__iand__ = intersection_update # type: ignore[assignment]
def symmetric_difference_update(self, other: Iterable[_T]) -> Self: ... # type: ignore[override]

View File

@@ -1,4 +1,4 @@
from _typeshed import Incomplete
import asyncio as asyncio
from ._compat_py3k import asynccontextmanager as asynccontextmanager
from ._concurrency_py3k import (
@@ -10,4 +10,4 @@ from ._concurrency_py3k import (
)
have_greenlet: bool
asyncio: Incomplete | None
greenlet_error: str | None

View File

@@ -7,6 +7,7 @@ from .langhelpers import (
)
SQLALCHEMY_WARN_20: bool
SILENCE_UBER_WARNING: bool
def warn_deprecated(msg, version, stacklevel: int = 3, code: Incomplete | None = None) -> None: ...
def warn_deprecated_limited(msg, args, version, stacklevel: int = 3, code: Incomplete | None = None) -> None: ...

View File

@@ -191,3 +191,7 @@ stubs/SQLAlchemy/sqlalchemy/sql/selectable.pyi
stubs/Flask-SQLAlchemy/flask_sqlalchemy/__init__.pyi
stubs/Flask-SQLAlchemy/flask_sqlalchemy/model.pyi
stubs/Flask-SQLAlchemy/flask_sqlalchemy/utils.pyi
# Uncertain why pytype is giving an error
# pytype.pytd.visitors.ContainerError
stubs/SQLAlchemy/sqlalchemy/sql/annotation.pyi