From 6b68fb04c92598bd77f9bee18ab2a1aa72bbd93a Mon Sep 17 00:00:00 2001 From: Trim21 Date: Thu, 17 Oct 2019 21:01:55 +0800 Subject: [PATCH] pymysql.Cursor is a context manager (#3379) --- third_party/2and3/pymysql/cursors.pyi | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third_party/2and3/pymysql/cursors.pyi b/third_party/2and3/pymysql/cursors.pyi index e08008541..48119ccd7 100644 --- a/third_party/2and3/pymysql/cursors.pyi +++ b/third_party/2and3/pymysql/cursors.pyi @@ -1,7 +1,9 @@ -from typing import Union, Tuple, Any, Dict, Optional, Text, Iterator, List +from typing import Any, Dict, Iterator, List, Optional, Text, Tuple, TypeVar, Union + from .connections import Connection Gen = Union[Tuple[Any, ...], Dict[str, Any]] +_SelfT = TypeVar("_SelfT") class Cursor: connection: Connection @@ -26,6 +28,8 @@ class Cursor: def fetchall(self) -> Optional[Tuple[Gen, ...]]: ... def scroll(self, value: int, mode: str = ...): ... def __iter__(self): ... + def __enter__(self: _SelfT) -> _SelfT: ... + def __exit__(self, *exc_info: Any) -> None: ... class DictCursor(Cursor): def fetchone(self) -> Optional[Dict[str, Any]]: ...