1
1
from typing import Any
2
2
from typing import Optional
3
+ from typing import TypeVar
4
+ from typing import Union
3
5
4
- from sqlalchemy . types import NullType as NullType
5
- from . import coercions as coercions
6
- from . import roles as roles
7
- from .base import ColumnCollection as ColumnCollection
8
- from .base import CompileState as CompileState
9
- from .base import DialectKWArgs as DialectKWArgs
10
- from .base import Executable as Executable
11
- from .base import HasCompileState as HasCompileState
12
- from .elements import BooleanClauseList as BooleanClauseList
13
- from .elements import ClauseElement as ClauseElement
14
- from .elements import Null as Null
15
- from . selectable import HasCTE as HasCTE
16
- from . selectable import HasPrefixes as HasPrefixes
17
- from . visitors import InternalTraversal as InternalTraversal
18
- from .. import exc as exc
19
- from .. import util as util
20
- from .. util import collections_abc as collections_abc
6
+ from . import roles
7
+ from .base import CompileState
8
+ from .base import DialectKWArgs
9
+ from .base import Executable
10
+ from .base import HasCompileState
11
+ from .base import ImmutableColumnCollection
12
+ from .elements import BooleanClauseList
13
+ from .elements import ClauseElement
14
+ from .schema import Table
15
+ from .selectable import HasCTE
16
+ from .selectable import HasPrefixes
17
+
18
+ _UB = TypeVar ( "_UB" , bound = UpdateBase )
19
+ _VB = TypeVar ( "_VB" , bound = ValuesBase )
20
+ _I = TypeVar ( "_I" , bound = Insert )
21
+ _DWB = TypeVar ( "_DWB" , bound = DMLWhereBase )
22
+ _UD = TypeVar ( "_UD" , bound = Update )
21
23
22
24
class DMLState (CompileState ):
23
25
isupdate : bool = ...
24
26
isdelete : bool = ...
25
27
isinsert : bool = ...
26
28
def __init__ (self , statement : Any , compiler : Any , ** kw : Any ) -> None : ...
27
29
@property
28
- def dml_table (self ): ...
30
+ def dml_table (self ) -> Table : ...
29
31
30
32
class InsertDMLState (DMLState ):
31
33
isinsert : bool = ...
@@ -37,7 +39,7 @@ class UpdateDMLState(DMLState):
37
39
isupdate : bool = ...
38
40
include_table_with_column_exprs : bool = ...
39
41
statement : Any = ...
40
- is_multitable : Any = ...
42
+ is_multitable : bool = ...
41
43
def __init__ (self , statement : Any , compiler : Any , ** kw : Any ) -> None : ...
42
44
43
45
class DeleteDMLState (DMLState ):
@@ -57,27 +59,26 @@ class UpdateBase(
57
59
__visit_name__ : str = ...
58
60
named_with_column : bool = ...
59
61
is_dml : bool = ...
60
- def params (self , * arg : Any , ** kw : Any ) -> None : ...
61
- def with_dialect_options (self , ** opt : Any ) -> None : ...
62
- def bind (self ): ...
63
62
bind : Any = ...
64
- def returning (self , * cols : Any ) -> None : ...
63
+ def params (self : _UB , * arg : Any , ** kw : Any ) -> _UB : ...
64
+ def with_dialect_options (self : _UB , ** opt : Any ) -> _UB : ...
65
+ def returning (self : _UB , * cols : Any ) -> _UB : ...
65
66
@property
66
- def exported_columns (self ): ...
67
+ def exported_columns (self ) -> ImmutableColumnCollection [ Any ] : ...
67
68
def with_hint (
68
- self ,
69
+ self : _UB ,
69
70
text : Any ,
70
71
selectable : Optional [Any ] = ...,
71
72
dialect_name : str = ...,
72
- ) -> None : ...
73
+ ) -> _UB : ...
73
74
74
75
class ValuesBase (UpdateBase ):
75
76
__visit_name__ : str = ...
76
77
select : Any = ...
77
78
table : Any = ...
78
79
def __init__ (self , table : Any , values : Any , prefixes : Any ) -> None : ...
79
- def values (self , * args : Any , ** kwargs : Any ) -> None : ...
80
- def return_defaults (self , * cols : Any ) -> None : ...
80
+ def values (self : _VB , * args : Any , ** kwargs : Any ) -> _VB : ...
81
+ def return_defaults (self : _VB , * cols : Any ) -> _VB : ...
81
82
82
83
class Insert (ValuesBase ):
83
84
__visit_name__ : str = ...
@@ -95,17 +96,19 @@ class Insert(ValuesBase):
95
96
return_defaults : bool = ...,
96
97
** dialect_kw : Any ,
97
98
) -> None : ...
98
- def inline (self ) -> None : ...
99
+ def inline (self : _I ) -> _I : ...
99
100
def from_select (
100
- self , names : Any , select : Any , include_defaults : bool = ...
101
- ) -> None : ...
101
+ self : _I , names : Any , select : Any , include_defaults : bool = ...
102
+ ) -> _I : ...
102
103
103
104
class DMLWhereBase :
104
- def where (self , * whereclause : Any ) -> None : ...
105
- def filter (self , * criteria : Any ): ...
106
- def filter_by (self , ** kwargs : Any ): ...
105
+ def where (self : _DWB , * whereclause : Any ) -> _DWB : ...
106
+ def filter (self : _DWB , * criteria : Any ) -> _DWB : ...
107
+ def filter_by (self : _DWB , ** kwargs : Any ) -> _DWB : ...
107
108
@property
108
- def whereclause (self ): ...
109
+ def whereclause (
110
+ self ,
111
+ ) -> Optional [Union [BooleanClauseList [Any ], ClauseElement ]]: ...
109
112
110
113
class Update (DMLWhereBase , ValuesBase ):
111
114
__visit_name__ : str = ...
@@ -123,8 +126,8 @@ class Update(DMLWhereBase, ValuesBase):
123
126
preserve_parameter_order : bool = ...,
124
127
** dialect_kw : Any ,
125
128
) -> None : ...
126
- def ordered_values (self , * args : Any ) -> None : ...
127
- def inline (self ) -> None : ...
129
+ def ordered_values (self : _UD , * args : Any ) -> _UD : ...
130
+ def inline (self : _UD ) -> _UD : ...
128
131
129
132
class Delete (DMLWhereBase , UpdateBase ):
130
133
__visit_name__ : str = ...
0 commit comments