Skip to content

Commit 7c80fd0

Browse files
committed
[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.
1 parent 13ffe24 commit 7c80fd0

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎stubs/ldap3/ldap3/extend/microsoft/persistentSearch.pyi‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterator
23

34
class ADPersistentSearch:
45
connection: Incomplete
@@ -12,4 +13,4 @@ class ADPersistentSearch:
1213
def start(self) -> None: ...
1314
def stop(self, unbind: bool = True) -> None: ...
1415
def next(self, block: bool = False, timeout=None): ...
15-
def funnel(self, block: bool = False, timeout=None) -> None: ...
16+
def funnel(self, block: bool = False, timeout=None) -> Iterator[Incomplete]: ...

‎stubs/ldap3/ldap3/extend/standard/PagedSearch.pyi‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from _typeshed import Incomplete
2+
from collections.abc import Iterator
3+
14
def paged_search_generator(
25
connection,
36
search_base,
@@ -12,7 +15,7 @@ def paged_search_generator(
1215
controls=None,
1316
paged_size: int = 100,
1417
paged_criticality: bool = False,
15-
) -> None: ...
18+
) -> Iterator[Incomplete]: ...
1619
def paged_search_accumulator(
1720
connection,
1821
search_base,

‎stubs/ldap3/ldap3/extend/standard/PersistentSearch.pyi‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from _typeshed import Incomplete
2+
from collections.abc import Iterator
23

34
class PersistentSearch:
45
connection: Incomplete
@@ -33,4 +34,4 @@ class PersistentSearch:
3334
def start(self) -> None: ...
3435
def stop(self, unbind: bool = True) -> None: ...
3536
def next(self, block: bool = False, timeout=None): ...
36-
def funnel(self, block: bool = False, timeout=None) -> None: ...
37+
def funnel(self, block: bool = False, timeout=None) -> Iterator[Incomplete]: ...

0 commit comments

Comments
 (0)