sqlite3: Avoid optional type for 'description' (#7842)

Use the `| Any` trick instead, since it seems that in a lot of
code the value can be predicted to be non-`None` (if a query
has been executed previously, I think).

The docs don't mention the possibility of this being `None`, so
it seems likely that a lot of code doesn't check for it:
https://docs.python.org/3/library/sqlite3.html#sqlite3.Cursor.description
This commit is contained in:
Jukka Lehtosalo
2022-05-16 13:54:15 +01:00
committed by GitHub
parent dca33e5f8d
commit 21a81c6575

View File

@@ -374,8 +374,9 @@ class Cursor(Iterator[Any]):
arraysize: int
@property
def connection(self) -> Connection: ...
# May be None, but using | Any instead to avoid slightly annoying false positives.
@property
def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...] | None: ...
def description(self) -> tuple[tuple[str, None, None, None, None, None, None], ...] | Any: ...
@property
def lastrowid(self) -> int | None: ...
row_factory: Callable[[Cursor, Row[Any]], object] | None