From 21a81c65750c1236bb4ccbf90a959681b25dc05e Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Mon, 16 May 2022 13:54:15 +0100 Subject: [PATCH] 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 --- stdlib/sqlite3/dbapi2.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index a6ccc9977..dc00a3971 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -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