forked from bschnurr/python-type-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqltypes.pyi
More file actions
370 lines (314 loc) · 15.1 KB
/
Copy pathsqltypes.pyi
File metadata and controls
370 lines (314 loc) · 15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
from typing import Any, Optional, Union, TypeVar, Dict, List, Tuple, Callable, Type, IO, overload, Text as typing_Text
from typing_extensions import Protocol
from .type_api import TypeEngine as TypeEngine, TypeDecorator as TypeDecorator, Emulated, NativeForEmulated as NativeForEmulated
from .base import SchemaEventTarget as SchemaEventTarget
from .schema import MetaData
from datetime import datetime, date, time, timedelta
from ..engine import Dialect, Engine, Connection, Connectable
from .. import util
import decimal
import sys
_T = TypeVar('_T')
class _LookupExpressionAdapter(object):
comparator_factory: Type[Any] = ...
class Concatenable(object):
comparator_factory: Type[Any] = ...
class Indexable(object):
comparator_factory: Type[Any] = ...
# Docs say that String is unicode when DBAPI supports it
# but it should be all major DBAPIs now.
class String(Concatenable, TypeEngine[typing_Text]):
__visit_name__: str = ...
length: Optional[int] = ...
collation: Optional[str] = ...
convert_unicode: Union[bool, str] = ...
unicode_error: Optional[str] = ...
@overload
def __init__(self, length: Optional[int] = ..., collation: Optional[str] = ...,
convert_unicode: bool = ..., _warn_on_bytestring: bool = ...) -> None: ...
@overload
def __init__(self, length: Optional[int] = ..., collation: Optional[str] = ...,
convert_unicode: str = ..., unicode_error: Optional[str] = ...,
_warn_on_bytestring: bool = ...) -> None: ...
def literal_processor(self, dialect: Dialect) -> Callable[[str], str]: ...
def bind_processor(self, dialect: Dialect) -> Optional[Callable[[str], str]]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Optional[Callable[[Optional[Any]], Optional[str]]]: ...
@property
def python_type(self) -> Type[typing_Text]: ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
class Text(String):
__visit_name__: str = ...
class Unicode(String):
__visit_name__: str = ...
@overload
def __init__(self, length: Optional[int] = ..., collation: Optional[str] = ...,
convert_unicode: bool = ..., _warn_on_bytestring: bool = ...) -> None: ...
@overload
def __init__(self, length: Optional[int] = ..., collation: Optional[str] = ...,
convert_unicode: str = ..., unicode_error: Optional[str] = ...,
_warn_on_bytestring: bool = ...) -> None: ...
class UnicodeText(Text):
__visit_name__: str = ...
@overload
def __init__(self, length: Optional[int] = ..., collation: Optional[str] = ...,
convert_unicode: bool = ..., _warn_on_bytestring: bool = ...) -> None: ...
@overload
def __init__(self, length: Optional[int] = ..., collation: Optional[str] = ...,
convert_unicode: str = ..., unicode_error: Optional[str] = ...,
_warn_on_bytestring: bool = ...) -> None: ...
class Integer(_LookupExpressionAdapter, TypeEngine[int]):
__visit_name__: str = ...
def get_dbapi_type(self, dbapi): ...
@property
def python_type(self) -> Type[int]: ...
def literal_processor(self, dialect: Dialect) -> Callable[[int], str]: ...
class SmallInteger(Integer):
__visit_name__: str = ...
class BigInteger(Integer):
__visit_name__: str = ...
# TODO: This can also be float (however, decimal is the default)
class Numeric(_LookupExpressionAdapter, TypeEngine[decimal.Decimal]):
__visit_name__: str = ...
precision: Optional[int] = ...
scale: Optional[int] = ...
decimal_return_scale: Optional[int] = ...
asdecimal: bool = ...
def __init__(self, precision: Optional[int] = ..., scale: Optional[int] = ...,
decimal_return_scale: Optional[int] = ..., asdecimal: bool = ...) -> None: ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
def literal_processor(self, dialect: Dialect) -> Callable[[Union[float, decimal.Decimal]], str]: ...
@property
def python_type(self) -> Union[Type[float], Type[decimal.Decimal]]: ... # type: ignore # return type incompatible
def bind_processor(self, dialect: Dialect) -> Optional[Callable[[Optional[str]], decimal.Decimal]]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Optional[Callable[[Optional[Any]],
Optional[Union[float, decimal.Decimal]]]]: ...
class Float(Numeric):
__visit_name__: str = ...
scale: Optional[int] = ...
precision: Optional[int] = ...
asdecimal: bool = ...
decimal_return_scale: Optional[int] = ...
def __init__(self, precision: Optional[int] = ..., asdecimal: bool = ...,
decimal_return_scale: Optional[int] = ..., **kwargs: Any) -> None: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Optional[Callable[[Optional[Any]],
Optional[Union[float, decimal.Decimal]]]]: ...
class DateTime(_LookupExpressionAdapter, TypeEngine[datetime]):
__visit_name__: str = ...
timezone: bool = ...
def __init__(self, timezone: bool = ...) -> None: ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
@property
def python_type(self) -> Type[datetime]: ...
class Date(_LookupExpressionAdapter, TypeEngine[date]):
__visit_name__: str = ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
@property
def python_type(self) -> Type[date]: ...
class Time(_LookupExpressionAdapter, TypeEngine[time]):
__visit_name__: str = ...
timezone: bool = ...
def __init__(self, timezone: bool = ...) -> None: ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
@property
def python_type(self) -> Type[time]: ...
if sys.version_info[0] < 3:
_BinaryType = str
else:
_BinaryType = bytes
class _Binary(TypeEngine[_BinaryType]):
length: int = ...
def __init__(self, length: Optional[int] = ...) -> None: ...
def literal_processor(self, dialect: Dialect) -> Callable[[_BinaryType], str]: ...
@property
def python_type(self) -> Type[_BinaryType]: ...
def bind_processor(self, dialect: Dialect) -> Optional[Callable[[_BinaryType], Any]]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Optional[Callable[[Optional[Any]], Optional[_BinaryType]]]: ...
def coerce_compared_value(self, op: Any, value: Any) -> TypeEngine[Any]: ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
class LargeBinary(_Binary):
__visit_name__: str = ...
def __init__(self, length: Optional[int] = ...) -> None: ...
class Binary(LargeBinary):
def __init__(self, length: Optional[int] = ...) -> None: ...
class SchemaType(SchemaEventTarget):
name: Optional[str] = ...
schema: Optional[str] = ...
metadata: Optional[MetaData] = ...
inherit_schema: bool = ...
def __init__(self, name: Optional[str] = ..., schema: Optional[str] = ...,
metadata: Optional[MetaData] = ..., inherit_schema: bool = ...,
quote: Optional[bool] = ..., _create_events: bool = ...) -> None: ...
def copy(self, **kw: Any) -> Any: ...
def adapt(self, cls: Type[_T], **kw: Any) -> _T: ...
@property
def bind(self) -> Optional[Union[Engine, Connection]]: ...
def create(self, bind: Optional[Connectable] = ..., checkfirst: bool = ...) -> None: ...
def drop(self, bind: Optional[Connectable] = ..., checkfirst: bool = ...) -> None: ...
_E = TypeVar('_E', bound=Enum)
class Enum(Emulated, String, SchemaType):
__visit_name__: str = ...
native_enum: bool = ...
create_constraint: bool = ...
validate_strings: bool = ...
enums: List[typing_Text] = ... # This is set inside _setup_for_values.
def __init__(self, *enums: Any, **kw: Any) -> None: ...
@property
def native(self) -> bool: ...
comparator_factory: Type[Any] = ...
def adapt_to_emulated(self, impltype: Type[_T], **kw: Any) -> _T: ...
def adapt(self, cls: Type[Any], **kw: Any) -> Any: ...
def literal_processor(self, dialect: Dialect): ...
def bind_processor(self, dialect: Dialect): ...
def result_processor(self, dialect: Dialect, coltype: Any): ...
def copy(self: _E, **kw: Any) -> _E: ...
@property
def python_type(self): ...
class _Pickler(Protocol):
if sys.version_info >= (3, 0):
def dump(self, obj: Any, file: IO[bytes], protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> None: ...
def dumps(self, obj: Any, protocol: Optional[int] = ..., *,
fix_imports: bool = ...) -> bytes: ...
def loads(self, bytes_object: bytes, *, fix_imports: bool = ...,
encoding: str = ..., errors: str = ...) -> Any: ...
def load(self, file: IO[bytes], *, fix_imports: bool = ..., encoding: str = ...,
errors: str = ...) -> Any: ...
else:
def dump(self, obj: Any, file: IO[bytes], protocol: Optional[int] = ...) -> None: ...
def dumps(self, obj: Any, protocol: Optional[int] = ...) -> bytes: ...
def load(self, file: IO[bytes]) -> Any: ...
def loads(self, string: bytes) -> Any: ...
class PickleType(TypeDecorator[Any]):
impl: Any = ... # impl is Type[TypeEngine[LargeBinary]] on the class, but TypeEngine[LargeBinary] on instances
protocol: int = ...
pickler: _Pickler = ...
comparator: Optional[Callable[[Any, Any], bool]] = ...
def __init__(self, protocol: int = ..., pickler: Optional[_Pickler] = ...,
comparator: Optional[Callable[[Any, Any], bool]] = ...) -> None: ...
def __reduce__(self) -> Tuple[Type[PickleType], Tuple[int, None, Optional[Callable[[Any, Any], bool]]]]: ...
def bind_processor(self, dialect: Dialect) -> Callable[[Optional[Any]], Optional[str]]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Callable[[Optional[Any]], Any]: ...
def compare_values(self, x: Any, y: Any) -> bool: ...
class Boolean(Emulated, TypeEngine[bool], SchemaType):
__visit_name__: str = ...
create_constraint: bool = ...
name: str = ...
def __init__(self, create_constraint: bool = ..., name: Optional[str] = ...,
_create_events: bool = ...) -> None: ...
@property
def python_type(self) -> Type[bool]: ...
def literal_processor(self, dialect: Dialect) -> Callable[[Optional[bool]], str]: ...
def bind_processor(self, dialect: Dialect) -> Callable[[Optional[bool]], Optional[Union[bool, int]]]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Optional[Callable[[Optional[int]], bool]]: ...
class _AbstractInterval(_LookupExpressionAdapter, TypeEngine[_T]):
def coerce_compared_value(self, op: Any, value: Any) -> TypeEngine[Any]: ...
# "comparator_factory" of "_LookupExpressionAdapter" and "TypeDecorator" are incompatible
class Interval(Emulated, _AbstractInterval[timedelta], TypeDecorator[timedelta]): # type: ignore
impl: Any = ... # impl is Type[TypeEngine[DateTime]] on the class, but TypeEngine[DateTime] on instances
epoch: datetime = ...
native: bool = ...
second_precision: Optional[float] = ...
day_precision: Optional[float] = ...
def __init__(self, native: bool = ..., second_precision: Optional[float] = ...,
day_precision: Optional[float] = ...) -> None: ...
def adapt_to_emulated(self, impltype: Type[Any], **kw: Any) -> Any: ...
@property
def python_type(self) -> Type[timedelta]: ...
def bind_processor(self, dialect: Dialect) -> Callable[[Optional[timedelta]], str]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Callable[[Optional[str]], Optional[timedelta]]: ...
_JSONT = Union[Dict[str, Any], List[Any]]
class JSON(Indexable, TypeEngine[_JSONT]):
__visit_name__: str = ...
hashable: bool = ...
NULL: util.symbol = ...
none_as_null: bool = ...
def __init__(self, none_as_null: bool = ...) -> None: ...
class JSONElementType(TypeEngine[Union[int, str]]):
def string_bind_processor(self, dialect): ...
def string_literal_processor(self, dialect): ...
def bind_processor(self, dialect): ...
def literal_processor(self, dialect): ...
class JSONIndexType(JSONElementType): ...
class JSONPathType(JSONElementType): ...
comparator_factory: Type[Any] = ...
# This method returns `dict`, but it seems to be a bug in SQLAlchemy.
@property
def python_type(self) -> Type[Dict[str, Any]]: ...
@property
def should_evaluate_none(self) -> bool: ... # type: ignore # incompatible with supertype "TypeEngine"
def bind_processor(self, dialect: Dialect) -> Callable[[Optional[_JSONT]], Optional[str]]: ...
def result_processor(self, dialect: Dialect, coltype: Any) -> Callable[[Optional[str]], Optional[_JSONT]]: ...
class ARRAY(Indexable, Concatenable, TypeEngine[List[_T]]):
__visit_name__: str = ...
zero_indexes: bool = ...
comparator_factory: Type[Any] = ...
item_type: TypeEngine[_T] = ...
as_tuple: bool = ...
dimensions: Optional[int] = ...
@overload
def __init__(self, item_type: TypeEngine[_T], as_tuple: bool = ..., dimensions: Optional[int] = ...,
zero_indexes: bool = ...) -> None: ...
@overload
def __init__(self, item_type: Type[TypeEngine[_T]], as_tuple: bool = ..., dimensions: Optional[int] = ...,
zero_indexes: bool = ...) -> None: ...
@property
def hashable(self) -> bool: ... # type: ignore # incompatible with supertype "TypeEngine"
@property
def python_type(self) -> Type[List[_T]]: ...
def compare_values(self, x: Any, y: Any) -> bool: ... # this function just does a simple comparison
class REAL(Float):
__visit_name__: str = ...
class FLOAT(Float):
__visit_name__: str = ...
class NUMERIC(Numeric):
__visit_name__: str = ...
class DECIMAL(Numeric):
__visit_name__: str = ...
class INTEGER(Integer):
__visit_name__: str = ...
INT = INTEGER
class SMALLINT(SmallInteger):
__visit_name__: str = ...
class BIGINT(BigInteger):
__visit_name__: str = ...
class TIMESTAMP(DateTime):
__visit_name__: str = ...
def __init__(self, timezone: bool = ...) -> None: ...
def get_dbapi_type(self, dbapi: Any) -> Any: ...
class DATETIME(DateTime):
__visit_name__: str = ...
class DATE(Date):
__visit_name__: str = ...
class TIME(Time):
__visit_name__: str = ...
class TEXT(Text):
__visit_name__: str = ...
class CLOB(Text):
__visit_name__: str = ...
class VARCHAR(String):
__visit_name__: str = ...
class NVARCHAR(Unicode):
__visit_name__: str = ...
class CHAR(String):
__visit_name__: str = ...
class NCHAR(Unicode):
__visit_name__: str = ...
class BLOB(LargeBinary):
__visit_name__: str = ...
class BINARY(_Binary):
__visit_name__: str = ...
class VARBINARY(_Binary):
__visit_name__: str = ...
class BOOLEAN(Boolean):
__visit_name__: str = ...
class NullType(TypeEngine[None]):
__visit_name__: str = ...
hashable: bool = ...
def literal_processor(self, dialect: Dialect) -> Callable[[Any], str]: ...
comparator_factory: Type[Any] = ...
class MatchType(Boolean): ...
NULLTYPE: NullType = ...
BOOLEANTYPE: Boolean = ...
STRINGTYPE: String = ...
INTEGERTYPE: Integer = ...
MATCHTYPE: MatchType = ...