Skip to content

Commit f37709f

Browse files
JelleZijlstragvanrossum
authored andcommitted
Merge stubs for sqlite3 (#2026)
As promised in #2014. There are virtually no real changes between Python 2 and 3 in this module, but the stub had accumulated some meaningless differences. I also fixed a few incorrect types.
1 parent 3f456e3 commit f37709f

File tree

4 files changed

+35
-284
lines changed

4 files changed

+35
-284
lines changed

stdlib/2/sqlite3/dbapi2.pyi

Lines changed: 0 additions & 259 deletions
This file was deleted.
File renamed without changes.

stdlib/3/sqlite3/dbapi2.pyi renamed to stdlib/2and3/sqlite3/dbapi2.pyi

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@
22
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
33

44
import sys
5-
from typing import Any, Union, List, Iterator, Optional, TypeVar, Callable
6-
from datetime import time, datetime
7-
from collections import Iterable
5+
from typing import Any, Callable, Iterable, Iterator, List, Optional, Text, Tuple, Type, TypeVar, Union
6+
from datetime import date, time, datetime
87

98
_T = TypeVar('_T')
109

11-
paramstyle = ... # type: str
12-
threadsafety = ... # type: int
13-
apilevel = ... # type: str
14-
Date = ... # type: datetime
15-
Time = ... # type: time
16-
Timestamp = ... # type: datetime
10+
paramstyle: str
11+
threadsafety: int
12+
apilevel: str
13+
Date = date
14+
Time = time
15+
Timestamp = datetime
1716

1817
def DateFromTicks(ticks): ...
1918
def TimeFromTicks(ticks): ...
2019
def TimestampFromTicks(ticks): ...
2120

22-
version_info = ... # type: Any
23-
sqlite_version_info = ... # type: Any
24-
Binary = ... # type: Any
21+
version_info: str
22+
sqlite_version_info: Tuple[int, int, int]
23+
Binary: Type[Any]
2524

2625
def register_adapters_and_converters(): ...
2726

@@ -69,21 +68,33 @@ version = ... # type: str
6968
def adapt(obj, protocol, alternate): ...
7069
def complete_statement(sql: str) -> bool: ...
7170
if sys.version_info >= (3, 4):
72-
def connect(database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Union[str, None] = ..., check_same_thread: bool = ..., factory: Union[Connection, None] = ..., cached_statements: int = ..., uri: bool = ...) -> Connection: ...
71+
def connect(database: Union[bytes, Text],
72+
timeout: float = ...,
73+
detect_types: int = ...,
74+
isolation_level: Optional[str] = ...,
75+
check_same_thread: bool = ...,
76+
factory: Optional[Type[Connection]] = ...,
77+
cached_statements: int = ...,
78+
uri: bool = ...) -> Connection: ...
7379
else:
74-
def connect(database: Union[bytes, str], timeout: float = ..., detect_types: int = ..., isolation_level: Union[str, None] = ..., check_same_thread: bool = ..., factory: Union[Connection, None] = ..., cached_statements: int = ...) -> Connection: ...
80+
def connect(database: Union[bytes, Text],
81+
timeout: float = ...,
82+
detect_types: int = ...,
83+
isolation_level: Optional[str] = ...,
84+
check_same_thread: bool = ...,
85+
factory: Optional[Type[Connection]] = ...,
86+
cached_statements: int = ...) -> Connection: ...
7587
def enable_callback_tracebacks(flag: bool) -> None: ...
7688
def enable_shared_cache(do_enable: int) -> None: ...
77-
def register_adapter(type: _T, callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ...
78-
# TODO: sqlite3.register_converter.__doc__ specifies callable as unknown
89+
def register_adapter(type: Type[_T], callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ...
7990
def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ...
8091

81-
class Cache:
92+
class Cache(object):
8293
def __init__(self, *args, **kwargs) -> None: ...
8394
def display(self, *args, **kwargs) -> None: ...
8495
def get(self, *args, **kwargs) -> None: ...
8596

86-
class Connection:
97+
class Connection(object):
8798
DataError = ... # type: Any
8899
DatabaseError = ... # type: Any
89100
Error = ... # type: Any
@@ -109,7 +120,7 @@ class Connection:
109120
def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ...
110121
# TODO: please check in executemany() if seq_of_parameters type is possible like this
111122
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]) -> Cursor: ...
112-
def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ...
123+
def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
113124
def interrupt(self, *args, **kwargs) -> None: ...
114125
def iterdump(self, *args, **kwargs) -> None: ...
115126
def rollback(self, *args, **kwargs) -> None: ...
@@ -142,7 +153,7 @@ class Cursor(Iterator[Any]):
142153
def close(self, *args, **kwargs): ...
143154
def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ...
144155
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ...
145-
def executescript(self, sql_script: Union[bytes, str]) -> Cursor: ...
156+
def executescript(self, sql_script: Union[bytes, Text]) -> Cursor: ...
146157
def fetchall(self) -> List[Any]: ...
147158
def fetchmany(self, size: Optional[int] = ...) -> List[Any]: ...
148159
def fetchone(self) -> Any: ...
@@ -168,7 +179,7 @@ class NotSupportedError(DatabaseError): ...
168179

169180
class OperationalError(DatabaseError): ...
170181

171-
class OptimizedUnicode:
182+
class OptimizedUnicode(object):
172183
maketrans = ... # type: Any
173184
def __init__(self, *args, **kwargs): ...
174185
def capitalize(self, *args, **kwargs): ...
@@ -233,12 +244,12 @@ class OptimizedUnicode:
233244
def __rmod__(self, other): ...
234245
def __rmul__(self, other): ...
235246

236-
class PrepareProtocol:
247+
class PrepareProtocol(object):
237248
def __init__(self, *args, **kwargs): ...
238249

239250
class ProgrammingError(DatabaseError): ...
240251

241-
class Row:
252+
class Row(object):
242253
def __init__(self, *args, **kwargs): ...
243254
def keys(self, *args, **kwargs): ...
244255
def __eq__(self, other): ...
@@ -252,7 +263,7 @@ class Row:
252263
def __lt__(self, other): ...
253264
def __ne__(self, other): ...
254265

255-
class Statement:
266+
class Statement(object):
256267
def __init__(self, *args, **kwargs): ...
257268

258269
class Warning(Exception): ...

stdlib/3/sqlite3/__init__.pyi

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)