Skip to content

Add some minor attributes and classes into stubs #213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
0d60397
Add missing types to Session
AlexRiina Mar 7, 2020
e2e9c28
Allow List as param to any_
brabadu Apr 8, 2020
5e33374
Add missing orderinglist funcs
brabadu Apr 15, 2020
ae180c9
Use Iterable instead of List for any_ param
brabadu Apr 16, 2020
676731e
Merge remote-tracking branch 'upstream/master'
May 19, 2020
9d17201
MapperExtension added to stubs
May 26, 2020
0e3897c
Set args parametr for Table.__init__
May 26, 2020
ec84d19
Merge remote-tracking branch 'alexriina/master'
May 27, 2020
fbe508d
Fix tests
May 28, 2020
853f6d8
add parents property to mutablebase
vharitonsky Jan 15, 2021
9a5903b
Merge pull request #1 from vharitonsky/master
brabadu Jan 15, 2021
6e76aae
Allow bool or string for relationship(passive_deletes=...) arg (#143)
wbolster Jan 8, 2021
59a508d
Update spec of sqlalchemy.ext.hybrid.hybrid_property (#142)
item4 Jan 8, 2021
ecf0f6e
Session merge should an object of the type passed (#165)
DeanWay Jan 8, 2021
a928eb9
Update external/mypy to 0.790 (#179)
KKawamura1 Jan 8, 2021
f0ee59c
Add type stub for sqlalchemy.orm.session.close_all_sessions (#147)
tvuotila Jan 8, 2021
9eebfd3
Type relationship as list (#154)
tiangolo Jan 8, 2021
2ed8b7e
Add CTE prefixes (#157)
tuffnatty Jan 8, 2021
2bb7a55
Make name argument optional (#158)
jdkandersson Jan 8, 2021
8f25e2e
Fix re-export of some names according to new PEP 484 rules (#198)
ilevkivskyi Jan 8, 2021
3941f82
Test with python 3.8 (#186)
tdamsma Jan 8, 2021
d1003ef
Fix single item query return type (#199)
ilevkivskyi Jan 8, 2021
f706db8
Fix in operator annotations (and corresponding imports) (#200)
ilevkivskyi Jan 11, 2021
a82fa7a
Bump version (#201)
ilevkivskyi Jan 12, 2021
78ff384
add methods to load
vharitonsky Mar 11, 2021
419eb44
Merge pull request #2 from vharitonsky/master
brabadu Mar 11, 2021
8824a69
Merge branch 'master' of github.com:dropbox/sqlalchemy-stubs
Mar 11, 2021
8e1fb36
add pool lesser known members
vharitonsky Mar 25, 2021
2b35fda
Merge pull request #3 from vharitonsky/master
brabadu Mar 25, 2021
553b016
add row
vharitonsky Jun 28, 2022
bd6f78e
add row
vharitonsky Jun 28, 2022
91916b5
Merge branch 'brabadu:master' into master
vharitonsky Jun 28, 2022
2f9e7e5
add clauses
vharitonsky Jun 28, 2022
63f59bd
add more
vharitonsky Jun 28, 2022
6e6b7a4
fix typo
vharitonsky Jun 29, 2022
db6fa0f
fix params
vharitonsky Jun 29, 2022
8e415de
add version
vharitonsky Jun 30, 2022
49417d1
add compile stat
vharitonsky Jul 3, 2022
4999070
add declarative base
vharitonsky May 4, 2023
a95ea2b
add missing stuff
vharitonsky May 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sqlalchemy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

from .sql import (
alias as alias,
all_ as all_,
Expand Down Expand Up @@ -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__ = ...
2 changes: 2 additions & 0 deletions sqlalchemy-stubs/engine/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
34 changes: 34 additions & 0 deletions sqlalchemy-stubs/engine/row.pyi
Original file line number Diff line number Diff line change
@@ -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): ...

1 change: 1 addition & 0 deletions sqlalchemy-stubs/engine/url.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
2 changes: 2 additions & 0 deletions sqlalchemy-stubs/ext/mutable.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class MutableBase(object):
@classmethod
def coerce(cls, key, value): ...
@property
def _parents(self): ...

class Mutable(MutableBase):
def changed(self): ...
Expand Down
7 changes: 5 additions & 2 deletions sqlalchemy-stubs/ext/orderinglist.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
Expand Down
25 changes: 24 additions & 1 deletion sqlalchemy-stubs/orm/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...

Expand Down Expand Up @@ -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: ...
1 change: 1 addition & 0 deletions sqlalchemy-stubs/orm/decl_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def _declarative_constructor(*args, **kwargs): ...
7 changes: 6 additions & 1 deletion sqlalchemy-stubs/orm/query.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand All @@ -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: ...
Expand Down
10 changes: 10 additions & 0 deletions sqlalchemy-stubs/orm/strategy_options.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ...
Expand Down
12 changes: 12 additions & 0 deletions sqlalchemy-stubs/pool.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
3 changes: 3 additions & 0 deletions sqlalchemy-stubs/sql/elements.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion sqlalchemy-stubs/sql/schema.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sqlalchemy-stubs/sql/selectable.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions sqlalchemy-stubs/util/langhelpers.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Optional
from typing import Any, Optional, Dict, TypeVar

def md5_hex(x): ...

Expand Down Expand Up @@ -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): ...
Expand Down