Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion third_party/2and3/sqlalchemy/engine/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from .base import Connection as Connection
from .base import Engine as Engine
from .base import RowProxy as RowProxy
from .base import Transaction as Transaction
from .result import RowProxy as RowProxy

def create_engine(*args, **kwargs): ...
def engine_from_config(configuration, prefix=..., **kwargs): ...
17 changes: 3 additions & 14 deletions third_party/2and3/sqlalchemy/engine/base.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
from typing import Any, List, Tuple
from .interfaces import Connectable

# Dummy until I figure out something better.
class Connectable:
pass

class Connection:
class Connection(Connectable):
def begin(self): ...
def execute(self, object, *multiparams, **params): ...

class Engine(object): ...

class RowProxy:
def items(self) -> List[Tuple[Any, Any]]: ...
def keys(self) -> List[Any]: ...
def values(self) -> List[Any]: ...
def __getitem__(self, key: str): ...
class Engine(Connectable): ...

class Transaction:
def commit(self): ...
Expand Down
13 changes: 13 additions & 0 deletions third_party/2and3/sqlalchemy/engine/interfaces.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from typing import Any, TYPE_CHECKING
from .result import ResultProxy

if TYPE_CHECKING:
from .base import Connection

class Connectable:
def execute(self, object, *multiparams: Any, **params: Any) -> ResultProxy: ...
def connect(self, **kwargs: Any) -> Connection: ...
def contextual_connect(self) -> Connection: ...
# Note: The return type `Any` should be a DB API 2 value type once defined
# TODO: See #1037
def scalar(self, object, *multiparams: Any, **params: Any) -> Any: ...
22 changes: 22 additions & 0 deletions third_party/2and3/sqlalchemy/engine/result.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import Any, Iterator, List, Mapping, Optional

# Note: The value type `Any` should be a DB API 2 value type once defined
# TODO: See #1037

class RowProxy(Mapping[str, Any]): ...

class ResultProxy(Iterator[RowProxy]):
def keys(self) -> List[str]: ...
def close(self) -> None: ...
def __iter__(self) -> Iterator[RowProxy]: ...
def fetchall(self) -> Iterator[RowProxy]: ...
def fetchmany(self, size: Optional[int]=None) -> Iterator[RowProxy]: ...
def fetchone(self) -> Optional[RowProxy]: ...
def first(self) -> Optional[RowProxy]: ...

# Note: The return type `Any` should be a DB API 2 value type once defined
# TODO: See #1037
def scalar(self) -> Any: ...

@property
def rowcount(self) -> int: ...
8 changes: 7 additions & 1 deletion third_party/2and3/sqlalchemy/sql/selectable.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ class ForUpdateArg(ClauseElement): ...
class SelectBase(Executable, FromClause): ...
class GenerativeSelect(SelectBase): ...
class CompoundSelect(GenerativeSelect): ...
class Select(HasPrefixes, HasSuffixes, GenerativeSelect): ...

class Select(HasPrefixes, HasSuffixes, GenerativeSelect):
def where(self, whereclause) -> Select: ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way these can have more specific types?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I plan to add them later once I get to the code that is using them.

def group_by(self, *clauses) -> Select: ...
def order_by(self, *clauses) -> Select: ...
def limit(self, limit: int) -> Select: ...

class ScalarSelect(Generative, Grouping): ...
class Exists(UnaryExpression): ...
class TextAsFrom(SelectBase): ...
Expand Down