1
- from _typeshed import SupportsLessThan
1
+ import sys
2
2
from typing import Any
3
3
from typing import Callable
4
4
from typing import Generic
@@ -27,14 +27,30 @@ INDEXABLE: Any
27
27
TABLEVALUE : Any
28
28
29
29
_T = TypeVar ("_T" )
30
+ _T_co = TypeVar ("_T_co" , covariant = True )
31
+ _T_contra = TypeVar ("_T_contra" , contravariant = True )
30
32
_U = TypeVar ("_U" )
31
33
32
- _TE = TypeVar (' _TE' , bound = TypeEngine [Any ])
33
- _NFE = TypeVar (' _NFE' , bound = NativeForEmulated )
34
- _TD = TypeVar (' _TD' , bound = TypeDecorator [Any ])
35
- _VT = TypeVar (' _VT' , bound = Variant [Any ])
34
+ _TE = TypeVar (" _TE" , bound = TypeEngine [Any ])
35
+ _NFE = TypeVar (" _NFE" , bound = NativeForEmulated )
36
+ _TD = TypeVar (" _TD" , bound = TypeDecorator [Any ])
37
+ _VT = TypeVar (" _VT" , bound = Variant [Any ])
36
38
37
- _SortKeyFunction = Callable [[Any ], SupportsLessThan ]
39
+ if sys .version_info [0 ] < 3 :
40
+ from _typeshed import SupportsLessThan
41
+
42
+ _SortKeyFunction = Callable [[Any ], SupportsLessThan ]
43
+ else :
44
+ _SortKeyFunction = Callable [[Any ], Any ]
45
+
46
+ class _LiteralProcessor (Protocol [_T_contra ]):
47
+ def __call__ (self , __value : Optional [_T_contra ]) -> str : ...
48
+
49
+ class _BindProcessor (Protocol [_T_contra ]):
50
+ def __call__ (self , __value : Optional [_T_contra ]) -> Optional [Any ]: ...
51
+
52
+ class _ResultProcessor (Protocol [_T_co ]):
53
+ def __call__ (self , __value : Optional [Any ]) -> Optional [_T_co ]: ...
38
54
39
55
class TypeEngine (Traversible , Generic [_T ]):
40
56
class Comparator (operators .ColumnOperators ):
@@ -56,9 +72,9 @@ class TypeEngine(Traversible, Generic[_T]):
56
72
self , dialect : Any , conn_type : Any
57
73
) -> Any : ...
58
74
def copy_value (self , value : _T ) -> _T : ...
59
- def literal_processor (self , dialect : Any ) -> Optional [Callable [[ Optional [ _T ]], str ]]: ...
60
- def bind_processor (self , dialect : Any ) -> Optional [Callable [[ Optional [ _T ]], Optional [ Any ] ]]: ...
61
- def result_processor (self , dialect : Any , coltype : Any ) -> Optional [Callable [[ Optional [ Any ]], Optional [ _T ] ]]: ...
75
+ def literal_processor (self , dialect : Any ) -> Optional [_LiteralProcessor [ _T ]]: ...
76
+ def bind_processor (self , dialect : Any ) -> Optional [_BindProcessor [ _T ]]: ...
77
+ def result_processor (self , dialect : Any , coltype : Any ) -> Optional [_ResultProcessor [ _T ]]: ...
62
78
def column_expression (self , colexpr : Any ) -> Any : ...
63
79
def bind_expression (self , bindvalue : Any ) -> Any : ...
64
80
def compare_values (self , x : Any , y : Any ) -> bool : ...
@@ -105,9 +121,9 @@ class TypeDecorator(SchemaEventTarget, TypeEngine[_T]):
105
121
def process_literal_param (self , value : Optional [_T ], dialect : Any ) -> str : ...
106
122
def process_bind_param (self , value : Optional [_T ], dialect : Any ) -> Any : ...
107
123
def process_result_value (self , value : Any , dialect : Any ) -> Optional [_T ]: ...
108
- def literal_processor (self , dialect : Any ) -> Callable [[ Optional [ _T ]], str ]: ...
109
- def bind_processor (self , dialect : Any ) -> Callable [[ Optional [ _T ]], Optional [ Any ] ]: ...
110
- def result_processor (self , dialect : Any , coltype : Any ) -> Callable [[ Optional [ Any ]], Optional [ _T ] ]: ...
124
+ def literal_processor (self , dialect : Any ) -> _LiteralProcessor [ _T ]: ...
125
+ def bind_processor (self , dialect : Any ) -> _BindProcessor [ _T ]: ...
126
+ def result_processor (self , dialect : Any , coltype : Any ) -> _ResultProcessor [ _T ]: ...
111
127
def bind_expression (self , bindparam : Any ) -> Any : ...
112
128
def column_expression (self , column : Any ) -> Any : ...
113
129
def coerce_compared_value (self , op : Any , value : Any ) -> Any : ...
0 commit comments