Skip to content

Commit 5e38b48

Browse files
authored
Improve engine.create (#91)
* Improve `engine.create` * Updates based on PR feedback
1 parent 23cd151 commit 5e38b48

File tree

1 file changed

+137
-7
lines changed

1 file changed

+137
-7
lines changed

sqlalchemy-stubs/engine/create.pyi

Lines changed: 137 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,146 @@
11
from typing import Any
2+
from typing import Callable
3+
from typing import Dict
4+
from typing import List
5+
from typing import Optional
6+
from typing import overload
7+
from typing import Type
28
from typing import Union
39

4-
from . import base as base
10+
from typing_extensions import Literal
11+
512
from .base import Engine
6-
from .mock import create_mock_engine as create_mock_engine
713
from .url import URL
8-
from .. import event as event
9-
from .. import exc as exc
10-
from .. import util as util
11-
from ..sql import compiler as compiler
14+
from ..future import Engine as FutureEngine
15+
from ..pool import Pool
1216

13-
def create_engine(url: Union[str, URL], **kwargs: Any) -> Engine: ...
17+
_Debug = Literal["debug"]
18+
_IsolationLevel = Literal[
19+
"SERIALIZABLE",
20+
"REPEATABLE READ",
21+
"READ COMMITTED",
22+
"READ UNCOMMITTED",
23+
"AUTOCOMMIT",
24+
]
25+
_ParamStyle = Literal["qmark", "numeric", "named", "format", "pyformat"]
26+
_ResetOnReturn = Literal["rollback", "commit"]
27+
@overload
28+
def create_engine(
29+
url: Union[str, URL],
30+
*,
31+
case_sensitive: bool = ...,
32+
connect_args: Dict[Any, Any] = ...,
33+
convert_unicode: bool = ...,
34+
creator: Callable[..., Any] = ...,
35+
echo: Union[bool, _Debug] = ...,
36+
echo_pool: Union[bool, _Debug] = ...,
37+
enable_from_linting: bool = ...,
38+
encoding: str = ...,
39+
execution_options: Dict[Any, Any] = ...,
40+
future: Literal[True],
41+
hide_parameters: bool = ...,
42+
implicit_returning: bool = ...,
43+
isolation_level: _IsolationLevel = ...,
44+
json_deserializer: Callable[..., Any] = ...,
45+
json_serializer: Callable[..., Any] = ...,
46+
label_length: Optional[int] = ...,
47+
listeners: Any = ...,
48+
logging_name: str = ...,
49+
max_identifier_length: Optional[int] = ...,
50+
max_overflow: int = ...,
51+
module: Optional[Any] = ...,
52+
paramstyle: Optional[_ParamStyle] = ...,
53+
pool: Optional[Pool] = ...,
54+
poolclass: Optional[Type[Pool]] = ...,
55+
pool_logging_name: str = ...,
56+
pool_pre_ping: bool = ...,
57+
pool_size: int = ...,
58+
pool_recycle: int = ...,
59+
pool_reset_on_return: Optional[_ResetOnReturn] = ...,
60+
pool_timeout: float = ...,
61+
pool_use_lifo: bool = ...,
62+
plugins: List[str] = ...,
63+
query_cache_size: int = ...,
64+
**kwargs: Any,
65+
) -> FutureEngine: ...
66+
@overload
67+
def create_engine(
68+
url: Union[str, URL],
69+
*,
70+
case_sensitive: bool = ...,
71+
connect_args: Dict[Any, Any] = ...,
72+
convert_unicode: bool = ...,
73+
creator: Callable[..., Any] = ...,
74+
echo: Union[bool, _Debug] = ...,
75+
echo_pool: Union[bool, _Debug] = ...,
76+
enable_from_linting: bool = ...,
77+
encoding: str = ...,
78+
execution_options: Dict[Any, Any] = ...,
79+
future: Literal[False] = ...,
80+
hide_parameters: bool = ...,
81+
implicit_returning: bool = ...,
82+
isolation_level: _IsolationLevel = ...,
83+
json_deserializer: Callable[..., Any] = ...,
84+
json_serializer: Callable[..., Any] = ...,
85+
label_length: Optional[int] = ...,
86+
listeners: Any = ...,
87+
logging_name: str = ...,
88+
max_identifier_length: Optional[int] = ...,
89+
max_overflow: int = ...,
90+
module: Optional[Any] = ...,
91+
paramstyle: Optional[_ParamStyle] = ...,
92+
pool: Optional[Pool] = ...,
93+
poolclass: Optional[Type[Pool]] = ...,
94+
pool_logging_name: str = ...,
95+
pool_pre_ping: bool = ...,
96+
pool_size: int = ...,
97+
pool_recycle: int = ...,
98+
pool_reset_on_return: Optional[_ResetOnReturn] = ...,
99+
pool_timeout: float = ...,
100+
pool_use_lifo: bool = ...,
101+
plugins: List[str] = ...,
102+
query_cache_size: int = ...,
103+
**kwargs: Any,
104+
) -> Engine: ...
105+
@overload
106+
def create_engine(
107+
url: Union[str, URL],
108+
*,
109+
case_sensitive: bool = ...,
110+
connect_args: Dict[Any, Any] = ...,
111+
convert_unicode: bool = ...,
112+
creator: Callable[..., Any] = ...,
113+
echo: Union[bool, _Debug] = ...,
114+
echo_pool: Union[bool, _Debug] = ...,
115+
enable_from_linting: bool = ...,
116+
encoding: str = ...,
117+
execution_options: Dict[Any, Any] = ...,
118+
future: Union[bool],
119+
hide_parameters: bool = ...,
120+
implicit_returning: bool = ...,
121+
isolation_level: _IsolationLevel = ...,
122+
json_deserializer: Callable[..., Any] = ...,
123+
json_serializer: Callable[..., Any] = ...,
124+
label_length: Optional[int] = ...,
125+
listeners: Any = ...,
126+
logging_name: str = ...,
127+
max_identifier_length: Optional[int] = ...,
128+
max_overflow: int = ...,
129+
module: Optional[Any] = ...,
130+
paramstyle: Optional[_ParamStyle] = ...,
131+
pool: Optional[Pool] = ...,
132+
poolclass: Optional[Type[Pool]] = ...,
133+
pool_logging_name: str = ...,
134+
pool_pre_ping: bool = ...,
135+
pool_size: int = ...,
136+
pool_recycle: int = ...,
137+
pool_reset_on_return: Optional[_ResetOnReturn] = ...,
138+
pool_timeout: float = ...,
139+
pool_use_lifo: bool = ...,
140+
plugins: List[str] = ...,
141+
query_cache_size: int = ...,
142+
**kwargs: Any,
143+
) -> Union[Engine, FutureEngine]: ...
14144
def engine_from_config(
15145
configuration: Any, prefix: str = ..., **kwargs: Any
16146
) -> Engine: ...

0 commit comments

Comments
 (0)