mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Iteration and fetch* fixes to the sqlite3.Cursor type (#663)
- Cursor is an Iterator of Any now, and .__iter__(..) and .__next__(..) have been changed / made explicit to reflect this. - .fetchall(..)/.fetchmany(..)/.fetchone(..) return (lists of) Anys instead of tuples. As per discussion in PR #663, the output of fetching values from the cursor can be customized with a custom assignment to .row_factory. Therefore the correct return type for fetching is Any and not tuple.
This commit is contained in:
committed by
Guido van Rossum
parent
3855e7023f
commit
69ea0ad43f
@@ -1,7 +1,7 @@
|
||||
# Filip Hron <filip.hron@gmail.com>
|
||||
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
|
||||
|
||||
from typing import Any, Union, List
|
||||
from typing import Any, Union, List, Iterator
|
||||
from numbers import Integral
|
||||
from datetime import time, datetime
|
||||
from collections import Iterable
|
||||
@@ -125,7 +125,7 @@ class Connection:
|
||||
def __enter__(self, *args, **kwargs): ...
|
||||
def __exit__(self, *args, **kwargs): ...
|
||||
|
||||
class Cursor:
|
||||
class Cursor(Iterator[Any]):
|
||||
arraysize = ... # type: Any
|
||||
connection = ... # type: Any
|
||||
description = ... # type: Any
|
||||
@@ -140,13 +140,14 @@ class Cursor:
|
||||
def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ...
|
||||
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ...
|
||||
def executescript(self, sql_script: Union[bytes, unicode]) -> Cursor: ...
|
||||
def fetchall(self) -> List[tuple]: ...
|
||||
def fetchmany(self, size: Integral = ...) -> List[tuple]: ...
|
||||
def fetchone(self) -> Union[tuple, None]: ...
|
||||
def fetchall(self) -> List[Any]: ...
|
||||
def fetchmany(self, size: Integral = ...) -> List[Any]: ...
|
||||
def fetchone(self) -> Any: ...
|
||||
def setinputsizes(self, *args, **kwargs): ...
|
||||
def setoutputsize(self, *args, **kwargs): ...
|
||||
def __iter__(self): ...
|
||||
def __next__(self): ...
|
||||
def __iter__(self) -> Cursor: ...
|
||||
def __next__(self) -> Any: ...
|
||||
|
||||
|
||||
class DataError(DatabaseError): ...
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Filip Hron <filip.hron@gmail.com>
|
||||
# based heavily on Andrey Vlasovskikh's python-skeletons https://github.com/JetBrains/python-skeletons/blob/master/sqlite3.py
|
||||
|
||||
from typing import Any, Union, List, AnyStr
|
||||
from typing import Any, Union, List, AnyStr, Iterator
|
||||
from numbers import Integral
|
||||
from datetime import time, datetime
|
||||
from collections import Iterable
|
||||
@@ -125,7 +125,7 @@ class Connection:
|
||||
def __enter__(self, *args, **kwargs): ...
|
||||
def __exit__(self, *args, **kwargs): ...
|
||||
|
||||
class Cursor:
|
||||
class Cursor(Iterator[Any]):
|
||||
arraysize = ... # type: Any
|
||||
connection = ... # type: Any
|
||||
description = ... # type: Any
|
||||
@@ -140,13 +140,14 @@ class Cursor:
|
||||
def execute(self, sql: str, parameters: Iterable = ...) -> Cursor: ...
|
||||
def executemany(self, sql: str, seq_of_parameters: Iterable[Iterable]): ...
|
||||
def executescript(self, sql_script: Union[bytes, AnyStr]) -> Cursor: ...
|
||||
def fetchall(self) -> List[tuple]: ...
|
||||
def fetchmany(self, size: Integral = ...) -> List[tuple]: ...
|
||||
def fetchone(self) -> Union[tuple, None]: ...
|
||||
def fetchall(self) -> List[Any]: ...
|
||||
def fetchmany(self, size: Integral = ...) -> List[Any]: ...
|
||||
def fetchone(self) -> Any: ...
|
||||
def setinputsizes(self, *args, **kwargs): ...
|
||||
def setoutputsize(self, *args, **kwargs): ...
|
||||
def __iter__(self): ...
|
||||
def __next__(self): ...
|
||||
def __iter__(self) -> Cursor: ...
|
||||
def __next__(self) -> Any: ...
|
||||
|
||||
|
||||
class DataError(DatabaseError): ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user