Skip to content

Commit 0709985

Browse files
jhrmnnmatthiaskramm
authored andcommitted
fix signatures of sqlite3.register_adapter/converter (#1390)
1 parent 16ec7cb commit 0709985

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

stdlib/3/sqlite3/dbapi2.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Filip Hron <filip.hron@gmail.com>
22
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
33

4-
from typing import Any, Union, List, Iterator, Optional
4+
import sys
5+
from typing import Any, Union, List, Iterator, Optional, TypeVar, Callable
56
from numbers import Integral
67
from datetime import time, datetime
78
from collections import Iterable
89

9-
import sys
10+
_T = TypeVar('_T')
1011

1112
paramstyle = ... # type: str
1213
threadsafety = ... # type: int
@@ -74,9 +75,9 @@ else:
7475
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: ...
7576
def enable_callback_tracebacks(flag: bool) -> None: ...
7677
def enable_shared_cache(do_enable: int) -> None: ...
77-
def register_adapter(type: type, callable: Any) -> None: ...
78+
def register_adapter(type: _T, callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ...
7879
# TODO: sqlite3.register_converter.__doc__ specifies callable as unknown
79-
def register_converter(typename: str, callable: bytes) -> None: ...
80+
def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ...
8081

8182
class Cache:
8283
def __init__(self, *args, **kwargs) -> None: ...

0 commit comments

Comments
 (0)