Skip to content

Commit 50836ea

Browse files
authored
Improve future.* (#103)
1 parent 3ea9280 commit 50836ea

File tree

3 files changed

+78
-27
lines changed

3 files changed

+78
-27
lines changed

sqlalchemy-stubs/future/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from typing import Any
2-
31
from .engine import Connection as Connection
42
from .engine import create_engine as create_engine
53
from .engine import Engine as Engine
4+
from ..sql.selectable import Select
65

7-
select: Any
6+
select = Select._create_future_select

sqlalchemy-stubs/future/engine.pyi

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,98 @@
11
from typing import Any
2+
from typing import Callable
3+
from typing import Dict
4+
from typing import List
5+
from typing import NoReturn
26
from typing import Optional
7+
from typing import Type
8+
from typing import Union
39

4-
from .. import util as util
5-
from ..engine import Connection as _LegacyConnection
6-
from ..engine import Engine as _LegacyEngine
7-
from ..engine.base import OptionEngineMixin as OptionEngineMixin
10+
from .. import util
11+
from ..engine.base import Connection as _LegacyConnection
12+
from ..engine.base import Engine as _LegacyEngine
13+
from ..engine.base import NestedTransaction
14+
from ..engine.base import OptionEngineMixin
15+
from ..engine.base import Transaction
16+
from ..engine.create import _Debug
17+
from ..engine.create import _IsolationLevel
18+
from ..engine.create import _ParamStyle
19+
from ..engine.create import _ResetOnReturn
20+
from ..engine.url import URL
21+
from ..pool import Pool
822

9-
NO_OPTIONS: Any
23+
NO_OPTIONS: util.immutabledict[Any, Any] = ...
1024

11-
def create_engine(*arg: Any, **kw: Any): ...
25+
def create_engine(
26+
url: Union[str, URL],
27+
*,
28+
case_sensitive: bool = ...,
29+
connect_args: Dict[Any, Any] = ...,
30+
convert_unicode: bool = ...,
31+
creator: Callable[..., Any] = ...,
32+
echo: Union[bool, _Debug] = ...,
33+
echo_pool: Union[bool, _Debug] = ...,
34+
enable_from_linting: bool = ...,
35+
encoding: str = ...,
36+
execution_options: Dict[Any, Any] = ...,
37+
hide_parameters: bool = ...,
38+
implicit_returning: bool = ...,
39+
isolation_level: _IsolationLevel = ...,
40+
json_deserializer: Callable[..., Any] = ...,
41+
json_serializer: Callable[..., Any] = ...,
42+
label_length: Optional[int] = ...,
43+
listeners: Any = ...,
44+
logging_name: str = ...,
45+
max_identifier_length: Optional[int] = ...,
46+
max_overflow: int = ...,
47+
module: Optional[Any] = ...,
48+
paramstyle: Optional[_ParamStyle] = ...,
49+
pool: Optional[Pool] = ...,
50+
poolclass: Optional[Type[Pool]] = ...,
51+
pool_logging_name: str = ...,
52+
pool_pre_ping: bool = ...,
53+
pool_size: int = ...,
54+
pool_recycle: int = ...,
55+
pool_reset_on_return: Optional[_ResetOnReturn] = ...,
56+
pool_timeout: float = ...,
57+
pool_use_lifo: bool = ...,
58+
plugins: List[str] = ...,
59+
query_cache_size: int = ...,
60+
**kw: Any,
61+
) -> Engine: ...
1262

1363
class Connection(_LegacyConnection):
14-
def begin(self): ...
15-
def begin_nested(self): ...
64+
def begin(self) -> Transaction: ...
65+
def begin_nested(self) -> NestedTransaction: ...
1666
def commit(self) -> None: ...
1767
def rollback(self) -> None: ...
1868
def close(self) -> None: ...
19-
def execute(
69+
def execute( # type: ignore[override]
2070
self,
2171
statement: Any,
2272
parameters: Optional[Any] = ...,
2373
execution_options: Optional[Any] = ...,
24-
): ...
25-
def scalar(
74+
) -> Any: ...
75+
def scalar( # type: ignore[override]
2676
self,
2777
statement: Any,
2878
parameters: Optional[Any] = ...,
2979
execution_options: Optional[Any] = ...,
30-
): ...
80+
) -> Any: ...
3181

3282
class Engine(_LegacyEngine):
33-
transaction: Any = ...
34-
run_callable: Any = ...
35-
execute: Any = ...
36-
scalar: Any = ...
37-
table_names: Any = ...
38-
has_table: Any = ...
83+
def transaction(self, *arg: Any, **kw: Any) -> NoReturn: ...
84+
def run_callable(self, *arg: Any, **kw: Any) -> NoReturn: ...
85+
def execute(self, *arg: Any, **kw: Any) -> NoReturn: ...
86+
def scalar(self, *arg: Any, **kw: Any) -> NoReturn: ...
87+
def table_names(self, *arg: Any, **kw: Any) -> NoReturn: ...
88+
def has_table(self, *arg: Any, **kw: Any) -> NoReturn: ...
3989
class _trans_ctx:
40-
conn: Any = ...
41-
def __init__(self, conn: Any) -> None: ...
42-
transaction: Any = ...
43-
def __enter__(self): ...
90+
conn: Connection = ...
91+
def __init__(self, conn: Connection) -> None: ...
92+
transaction: Transaction = ...
93+
def __enter__(self) -> Connection: ...
4494
def __exit__(self, type_: Any, value: Any, traceback: Any) -> None: ...
45-
def begin(self): ...
46-
def connect(self): ...
95+
def begin(self) -> _trans_ctx: ... # type: ignore[override]
96+
def connect(self) -> Connection: ... # type: ignore[override]
4797

4898
class OptionEngine(OptionEngineMixin, Engine): ...

sqlalchemy-stubs/sql/selectable.pyi

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ class Select(
532532
) -> _SEL: ...
533533
@classmethod
534534
def _create(cls, *args: Any, **kw: Any) -> Select: ...
535+
@classmethod
536+
def _create_future_select(cls: Type[_SEL], *entities: Any) -> _SEL: ...
535537
def __init__(self) -> None: ...
536538
def filter(self: _SEL, *criteria: Any) -> _SEL: ...
537539
def filter_by(self: _SEL, **kwargs: Any) -> _SEL: ...

0 commit comments

Comments
 (0)