Skip to content

Commit 317a34f

Browse files
fxleblancilevkivskyi
authored andcommitted
Add types to execute method parameter statement (#119)
1 parent 9b9d26e commit 317a34f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

sqlalchemy-stubs/engine/base.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
from typing import Any, Optional, Dict
1+
from typing import Any, Optional, Dict, Union
22
from sqlalchemy import log
3+
from sqlalchemy.sql.expression import ClauseElement
4+
from sqlalchemy.sql.functions import FunctionElement
5+
from sqlalchemy.schema import DDLElement, DefaultGenerator
6+
from sqlalchemy.engine.interfaces import Compiled
37
from .interfaces import Connectable as Connectable, ExceptionContext as ExceptionContext
8+
from .result import ResultProxy
49

510
class Transaction(object):
611
connection: Any = ...
@@ -97,7 +102,10 @@ class Engine(Connectable, log.Identified):
97102
def begin(self, close_with_result: bool = ...): ...
98103
def transaction(self, callable_, *args, **kwargs): ...
99104
def run_callable(self, callable_, *args, **kwargs): ...
100-
def execute(self, statement, *multiparams, **params): ...
105+
def execute(self,
106+
object: Union[str, ClauseElement, FunctionElement, DDLElement, DefaultGenerator, Compiled],
107+
*multiparams: Any,
108+
**params: Any) -> ResultProxy: ...
101109
def scalar(self, statement, *multiparams, **params): ...
102110
def connect(self, **kwargs) -> Connection: ...
103111
def contextual_connect(self, close_with_result: bool = ..., **kwargs): ...

sqlalchemy-stubs/engine/interfaces.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from typing import Any, Optional
1+
from typing import Any, Optional, Union
2+
from sqlalchemy.sql.expression import ClauseElement
3+
from sqlalchemy.sql.functions import FunctionElement
4+
from sqlalchemy.schema import DDLElement, DefaultGenerator
25
from .base import Connection
36
from .result import ResultProxy
47
from ..sql.compiler import Compiled as Compiled, TypeCompiler as TypeCompiler
@@ -77,7 +80,10 @@ class Connectable(object):
7780
def contextual_connect(self) -> Connection: ...
7881
def create(self, entity, **kwargs): ...
7982
def drop(self, entity, **kwargs): ...
80-
def execute(self, object, *multiparams: Any, **params: Any) -> ResultProxy: ...
83+
def execute(self,
84+
object: Union[str, ClauseElement, FunctionElement, DDLElement, DefaultGenerator, Compiled],
85+
*multiparams: Any,
86+
**params: Any) -> ResultProxy: ...
8187
def scalar(self, object, *multiparams: Any, **params: Any) -> Any: ...
8288

8389
class ExceptionContext(object):

0 commit comments

Comments
 (0)