From 0709985d0c676127eae16e18e5710416a9ec6da8 Mon Sep 17 00:00:00 2001 From: Jan Hermann Date: Wed, 7 Jun 2017 03:09:08 +0200 Subject: [PATCH] fix signatures of sqlite3.register_adapter/converter (#1390) --- stdlib/3/sqlite3/dbapi2.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/3/sqlite3/dbapi2.pyi b/stdlib/3/sqlite3/dbapi2.pyi index 2c47843e5..ea1e28dba 100644 --- a/stdlib/3/sqlite3/dbapi2.pyi +++ b/stdlib/3/sqlite3/dbapi2.pyi @@ -1,12 +1,13 @@ # Filip Hron # based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py -from typing import Any, Union, List, Iterator, Optional +import sys +from typing import Any, Union, List, Iterator, Optional, TypeVar, Callable from numbers import Integral from datetime import time, datetime from collections import Iterable -import sys +_T = TypeVar('_T') paramstyle = ... # type: str threadsafety = ... # type: int @@ -74,9 +75,9 @@ else: 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: ... def enable_callback_tracebacks(flag: bool) -> None: ... def enable_shared_cache(do_enable: int) -> None: ... -def register_adapter(type: type, callable: Any) -> None: ... +def register_adapter(type: _T, callable: Callable[[_T], Union[int, float, str, bytes]]) -> None: ... # TODO: sqlite3.register_converter.__doc__ specifies callable as unknown -def register_converter(typename: str, callable: bytes) -> None: ... +def register_converter(typename: str, callable: Callable[[bytes], Any]) -> None: ... class Cache: def __init__(self, *args, **kwargs) -> None: ...