diff --git a/sqlalchemy-stubs/__init__.pyi b/sqlalchemy-stubs/__init__.pyi index fbed294..5f22437 100644 --- a/sqlalchemy-stubs/__init__.pyi +++ b/sqlalchemy-stubs/__init__.pyi @@ -1,3 +1,4 @@ + from .sql import ( alias as alias, all_ as all_, @@ -140,3 +141,5 @@ from . import pool as pool from . import processors as processors from . import schema as schema from . import types as types + +__version__ = ... diff --git a/sqlalchemy-stubs/engine/__init__.pyi b/sqlalchemy-stubs/engine/__init__.pyi index f4a89e0..ceb7e05 100644 --- a/sqlalchemy-stubs/engine/__init__.pyi +++ b/sqlalchemy-stubs/engine/__init__.pyi @@ -30,5 +30,7 @@ from .result import ( RowProxy as RowProxy, ) +from .row import Row + def create_engine(*args: Any, **kwargs: Any) -> Engine: ... def engine_from_config(configuration: Any, prefix: str = ..., **kwargs: Any) -> Engine: ... diff --git a/sqlalchemy-stubs/engine/row.pyi b/sqlalchemy-stubs/engine/row.pyi new file mode 100644 index 0000000..a7acf85 --- /dev/null +++ b/sqlalchemy-stubs/engine/row.pyi @@ -0,0 +1,34 @@ +import sys + +from typing import Any, List, Mapping, Union, AbstractSet, Tuple +from ..sql.schema import Column + +if sys.version_info >= (3, 0): + _RowItems = AbstractSet[Tuple[str, Any]] +else: + _RowItems = List[Tuple[str, Any]] + +class BaseRow(Mapping[str, Any]): + def __init__(self, parent, row, processors, keymap, data) -> None: ... + def __reduce__(self): ... + def values(self): ... + def __iter__(self): ... + def __len__(self) -> int: ... + def __getitem__(self, key: Union[str, int, Column]) -> Any: ... + def __getattr__(self, name): ... + +class Row(BaseRow): + def __contains__(self, key): ... + __hash__: Any = ... + def __lt__(self, other): ... + def __le__(self, other): ... + def __ge__(self, other): ... + def __gt__(self, other): ... + def __eq__(self, other): ... + def __ne__(self, other): ... + def has_key(self, key): ... + def items(self) -> _RowItems: ... + def keys(self): ... + def iterkeys(self): ... + def itervalues(self): ... + diff --git a/sqlalchemy-stubs/engine/url.pyi b/sqlalchemy-stubs/engine/url.pyi index 742e734..a4936d8 100644 --- a/sqlalchemy-stubs/engine/url.pyi +++ b/sqlalchemy-stubs/engine/url.pyi @@ -18,5 +18,6 @@ class URL(object): def get_driver_name(self): ... def get_dialect(self): ... def translate_connect_args(self, names: Any = ..., **kw): ... + def set(self, **kw): ... def make_url(name_or_url: Union[Text, bytes]) -> URL: ... diff --git a/sqlalchemy-stubs/ext/mutable.pyi b/sqlalchemy-stubs/ext/mutable.pyi index f68846b..375b96c 100644 --- a/sqlalchemy-stubs/ext/mutable.pyi +++ b/sqlalchemy-stubs/ext/mutable.pyi @@ -1,6 +1,8 @@ class MutableBase(object): @classmethod def coerce(cls, key, value): ... + @property + def _parents(self): ... class Mutable(MutableBase): def changed(self): ... diff --git a/sqlalchemy-stubs/ext/orderinglist.pyi b/sqlalchemy-stubs/ext/orderinglist.pyi index 65387ad..48347c4 100644 --- a/sqlalchemy-stubs/ext/orderinglist.pyi +++ b/sqlalchemy-stubs/ext/orderinglist.pyi @@ -1,10 +1,13 @@ -from typing import Any, Optional +from typing import Any, Optional, Callable def ordering_list(attr, count_from: Optional[Any] = ..., **kw): ... +def count_from_1(index: int, collection: Any) -> Any: ... +def count_from_0(index: int, collection: Any) -> Any: ... +def count_from_n_factory(start: int) -> Callable[[int, Any], Any]: ... class OrderingList(list): ordering_attr: str = ... - ordering_func: Any = ... + ordering_func: Callable[[int, Any], Any] = ... reorder_on_append: Any = ... def __init__(self, ordering_attr: Optional[str] = ..., ordering_func: Optional[Any] = ..., reorder_on_append: bool = ...) -> None: ... diff --git a/sqlalchemy-stubs/orm/__init__.pyi b/sqlalchemy-stubs/orm/__init__.pyi index 6527e6c..2c47f36 100644 --- a/sqlalchemy-stubs/orm/__init__.pyi +++ b/sqlalchemy-stubs/orm/__init__.pyi @@ -41,6 +41,7 @@ from .scoping import scoped_session as scoped_session from . import mapper as mapperlib from .query import AliasOption as AliasOption, Query as Query, Bundle as Bundle from .strategy_options import Load as Load +from ..ext.declarative import DeclarativeMeta def create_session(bind: Optional[Any] = ..., **kwargs): ... @@ -87,5 +88,27 @@ selectin_polymorphic: Any = ... def eagerload(*args, **kwargs): ... def eagerload_all(*args, **kwargs): ... - +def declarative_base(*args, **kwargs): ... contains_alias = AliasOption + + +class MapperExtension: + @classmethod + def _adapt_instrument_class(cls, self, listener) -> None: ... + + @classmethod + def _adapt_listener(cls, self, listener) -> None: ... + + @classmethod + def _adapt_listener_methods(cls, self, listener, methods) -> None: ... + + def instrument_class(self, mapper, class_) -> Any: ... + def init_instance(self, mapper, class_, oldinit, instance, args, kwargs) -> Any: ... + def init_failed(self, mapper, class_, oldinit, instance, args, kwargs) -> Any: ... + def reconstruct_instance(self, mapper, instance) -> Any: ... + def before_insert(self, mapper, connection, instance) -> Any: ... + def after_insert(self, mapper, connection, instance) -> Any: ... + def before_update(self, mapper, connection, instance) -> Any: ... + def after_update(self, mapper, connection, instance) -> Any: ... + def before_delete(self, mapper, connection, instance) -> Any: ... + def after_delete(self, mapper, connection, instance) -> Any: ... diff --git a/sqlalchemy-stubs/orm/decl_base.py b/sqlalchemy-stubs/orm/decl_base.py new file mode 100644 index 0000000..080f4f6 --- /dev/null +++ b/sqlalchemy-stubs/orm/decl_base.py @@ -0,0 +1 @@ +def _declarative_constructor(*args, **kwargs): ... diff --git a/sqlalchemy-stubs/orm/query.pyi b/sqlalchemy-stubs/orm/query.pyi index bc89cdd..22c2f9b 100644 --- a/sqlalchemy-stubs/orm/query.pyi +++ b/sqlalchemy-stubs/orm/query.pyi @@ -12,8 +12,12 @@ _Q = TypeVar('_Q', bound="Query") class Query(Generic[_T]): session: Session = ... - def __init__(self, entities, session: Optional[Session] = ...) -> None: ... + _limit_clause: Any = ... + _offset_clause: Any = ... + _group_by_clauses: Any = ... + def __init__(self, entities, session: Optional[Session] = ...) -> None: ... + def __next__(self): ... # TODO: is "statement" always of type sqlalchemy.sql.selectable.Select ? @property def statement(self): ... @@ -24,6 +28,7 @@ class Query(Generic[_T]): @property def selectable(self): ... def __clause_element__(self): ... + def _compile_state(self):... def enable_eagerloads(self: _Q, value: bool) -> _Q: ... def with_labels(self: _Q) -> _Q: ... def enable_assertions(self: _Q, value: bool) -> _Q: ... diff --git a/sqlalchemy-stubs/orm/strategy_options.pyi b/sqlalchemy-stubs/orm/strategy_options.pyi index 5f05fff..e57c59d 100644 --- a/sqlalchemy-stubs/orm/strategy_options.pyi +++ b/sqlalchemy-stubs/orm/strategy_options.pyi @@ -16,6 +16,16 @@ class Load(Generative, MapperOption): def process_query_conditionally(self, query): ... def set_relationship_strategy(self, attr, strategy, propagate_to_loaders: bool = ...): ... def set_column_strategy(self, attrs, strategy, opts: Optional[Any] = ..., opts_only: bool = ...): ... + def load_only(self, *attrs): ... + def joinedload(self, attr): ... + def subqueryload(self, attr): ... + def immediateload(self, attr): ... + def noload(self, attr): ... + def raiseload(self, attr, sql_only: bool = ...): ... + def defaultload(self, attr): ... + def defer(self, key): ... + def undefer(self, key): ... + def undefer_group(self, name): ... class _UnboundLoad(Load): path: Any = ... diff --git a/sqlalchemy-stubs/pool.pyi b/sqlalchemy-stubs/pool.pyi index 4269ebe..e462d7e 100644 --- a/sqlalchemy-stubs/pool.pyi +++ b/sqlalchemy-stubs/pool.pyi @@ -58,3 +58,15 @@ class AssertionPool(Pool): def status(self): ... def dispose(self): ... def recreate(self): ... + +class _ConnectionFairy: + def cursor(self): ... + def info(self): ... + def record_info(self): ... + def invalidate(self): ... + def detach(self): ... + def close(self): ... + +class _ConnectionRecord(object): + def info(self): ... + def checkout(self, pool): ... diff --git a/sqlalchemy-stubs/sql/elements.pyi b/sqlalchemy-stubs/sql/elements.pyi index cb9a64f..b38f0f9 100644 --- a/sqlalchemy-stubs/sql/elements.pyi +++ b/sqlalchemy-stubs/sql/elements.pyi @@ -298,6 +298,9 @@ class CollectionAggregate(UnaryExpression[_T]): @overload @classmethod def _create_any(cls, expr: ClauseElement) -> CollectionAggregate[Any]: ... + @overload + @classmethod + def _create_any(cls, expr: Iterable[Any]) -> CollectionAggregate[Any]: ... _AB = TypeVar('_AB', bound=AsBoolean) diff --git a/sqlalchemy-stubs/sql/schema.pyi b/sqlalchemy-stubs/sql/schema.pyi index 4d24906..8532387 100644 --- a/sqlalchemy-stubs/sql/schema.pyi +++ b/sqlalchemy-stubs/sql/schema.pyi @@ -6,7 +6,7 @@ from . import visitors, functions from .base import SchemaEventTarget as SchemaEventTarget, DialectKWArgs as DialectKWArgs, ColumnCollection from .elements import ColumnClause as ColumnClause, TextClause, ColumnElement from .selectable import TableClause as TableClause -from .type_api import TypeEngine +from .type_api import TypeEngine, TypeDecorator, Variant from .. import util from ..engine import Engine, Connection, Connectable from ..engine.url import URL diff --git a/sqlalchemy-stubs/sql/selectable.pyi b/sqlalchemy-stubs/sql/selectable.pyi index 74a5000..ce6024b 100644 --- a/sqlalchemy-stubs/sql/selectable.pyi +++ b/sqlalchemy-stubs/sql/selectable.pyi @@ -82,6 +82,7 @@ class Join(FromClause): def self_group(self, against: Optional[Any] = ...) -> FromGrouping: ... def get_children(self, **kwargs: Any) -> Tuple[FromClause, FromClause, ClauseElement]: ... def select(self, whereclause: Optional[Union[str, bool, Visitable]] = ..., **kwargs: Any) -> Select: ... + def where(self: _SE, whereclause: Union[str, bool, Visitable]) -> _SE: ... @property def bind(self) -> Optional[Union[Engine, Connection]]: ... # Return type of "alias" incompatible with supertype "FromClause" diff --git a/sqlalchemy-stubs/util/langhelpers.pyi b/sqlalchemy-stubs/util/langhelpers.pyi index c1147be..6d4e9b4 100644 --- a/sqlalchemy-stubs/util/langhelpers.pyi +++ b/sqlalchemy-stubs/util/langhelpers.pyi @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any, Optional, Dict, TypeVar def md5_hex(x): ... @@ -98,7 +98,7 @@ class hybridmethod(object): def __get__(self, instance, owner): ... class symbol(object): - symbols: Any = ... + symbols: Dict[str, Any] def __new__(cls, name, doc: Optional[Any] = ..., canonical: Optional[Any] = ...): ... def set_creation_order(instance): ...