From 7c80fd092e6b9c1bcfe4029f4d020f7e127f708a Mon Sep 17 00:00:00 2001 From: dhairya05 Date: Fri, 6 Nov 2026 22:55:55 +0530 Subject: [PATCH] [ldap3] Annotate generator functions as returning iterators `paged_search_generator`, `PersistentSearch.funnel` and `ADPersistentSearch.funnel` are generators, but were declared `-> None`, so iterating them was a type error: for entry in paged_search_generator(conn, base, "(objectClass=*)"): ... # error: "None" has no attribute "__iter__" (not iterable) All three yield outside any nested function in ldap3 2.9.1: `paged_search_generator` yields entries off the response list, and both `funnel` methods yield search result entries. Annotated `Iterator[Incomplete]` to match the element type the rest of these stubs use; the sibling `next` methods are deliberately left unannotated as they already were. stubtest reports the same single pre-existing error before and after (`ldap3.protocol.sasl.kerberos` needs the optional gssapi package), and mypy reports the same 25 pre-existing pyasn1 import errors. pyright is clean. --- stubs/ldap3/ldap3/extend/microsoft/persistentSearch.pyi | 3 ++- stubs/ldap3/ldap3/extend/standard/PagedSearch.pyi | 5 ++++- stubs/ldap3/ldap3/extend/standard/PersistentSearch.pyi | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/stubs/ldap3/ldap3/extend/microsoft/persistentSearch.pyi b/stubs/ldap3/ldap3/extend/microsoft/persistentSearch.pyi index 5c39dfc8b0b8..2de0c2ab581b 100644 --- a/stubs/ldap3/ldap3/extend/microsoft/persistentSearch.pyi +++ b/stubs/ldap3/ldap3/extend/microsoft/persistentSearch.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterator class ADPersistentSearch: connection: Incomplete @@ -12,4 +13,4 @@ class ADPersistentSearch: def start(self) -> None: ... def stop(self, unbind: bool = True) -> None: ... def next(self, block: bool = False, timeout=None): ... - def funnel(self, block: bool = False, timeout=None) -> None: ... + def funnel(self, block: bool = False, timeout=None) -> Iterator[Incomplete]: ... diff --git a/stubs/ldap3/ldap3/extend/standard/PagedSearch.pyi b/stubs/ldap3/ldap3/extend/standard/PagedSearch.pyi index d651eff6afda..5e73e5c29fef 100644 --- a/stubs/ldap3/ldap3/extend/standard/PagedSearch.pyi +++ b/stubs/ldap3/ldap3/extend/standard/PagedSearch.pyi @@ -1,3 +1,6 @@ +from _typeshed import Incomplete +from collections.abc import Iterator + def paged_search_generator( connection, search_base, @@ -12,7 +15,7 @@ def paged_search_generator( controls=None, paged_size: int = 100, paged_criticality: bool = False, -) -> None: ... +) -> Iterator[Incomplete]: ... def paged_search_accumulator( connection, search_base, diff --git a/stubs/ldap3/ldap3/extend/standard/PersistentSearch.pyi b/stubs/ldap3/ldap3/extend/standard/PersistentSearch.pyi index 8b059d36c29e..0993c7f000df 100644 --- a/stubs/ldap3/ldap3/extend/standard/PersistentSearch.pyi +++ b/stubs/ldap3/ldap3/extend/standard/PersistentSearch.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from collections.abc import Iterator class PersistentSearch: connection: Incomplete @@ -33,4 +34,4 @@ class PersistentSearch: def start(self) -> None: ... def stop(self, unbind: bool = True) -> None: ... def next(self, block: bool = False, timeout=None): ... - def funnel(self, block: bool = False, timeout=None) -> None: ... + def funnel(self, block: bool = False, timeout=None) -> Iterator[Incomplete]: ...