From 79c654ef43a183ba7ae49de52c9f7b89a17043b4 Mon Sep 17 00:00:00 2001 From: Bao Date: Thu, 7 Apr 2022 17:36:26 -0500 Subject: [PATCH] psycopg2: correct return type (#7607) Fixes the return type of `psycopg2.cursor.fetchone()` to match the psycopg2 code: https://github.com/psycopg/psycopg2/blob/1d3a89a0bba621dc1cc9b32db6d241bd2da85ad1/psycopg/cursor_type.c#L647-L651 https://github.com/psycopg/psycopg2/blob/1d3a89a0bba621dc1cc9b32db6d241bd2da85ad1/psycopg/cursor_type.c#L748-L786 It also matches the [psycopg2 documentation](https://www.psycopg.org/docs/cursor.html?highlight=copy_from#cursor.fetchone) as well as the [DB-API](https://peps.python.org/pep-0249/#fetchone) --- stubs/psycopg2/psycopg2/_psycopg.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/psycopg2/psycopg2/_psycopg.pyi b/stubs/psycopg2/psycopg2/_psycopg.pyi index 02c018b13..bde672976 100644 --- a/stubs/psycopg2/psycopg2/_psycopg.pyi +++ b/stubs/psycopg2/psycopg2/_psycopg.pyi @@ -368,7 +368,7 @@ class cursor: def executemany(self, query: str | bytes | Composable, vars_list: Iterable[_Vars]) -> None: ... def fetchall(self) -> list[tuple[Any, ...]]: ... def fetchmany(self, size=...) -> list[tuple[Any, ...]]: ... - def fetchone(self) -> tuple[Any, ...] | Any: ... + def fetchone(self) -> tuple[Any, ...] | None: ... def mogrify(self, *args, **kwargs): ... def nextset(self): ... def scroll(self, value, mode=...): ...