Repository navigation
[ldap3] Annotate generator functions as returning iterators - #16723
Open
Dhairya-007 wants to merge 1 commit into
Open
Dhairya-007 wants to merge 1 commit into
Dhairya-007 wants to merge 1 commit into
Conversation
`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.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
paged_search_generator,PersistentSearch.funnelandADPersistentSearch.funnelare generators, but all three were declared-> None, so iterating them — the only way to use them — was a type error:A short usage file reports 4 errors before this change and none after.
Checked against ldap3 2.9.1: each one contains a
yieldoutside any nested function.paged_search_generatoryields entries off the response list (yield responses.pop()), and bothfunnelmethods yield search result entries from the event queue.Annotated as
Iterator[Incomplete], matching the element type used throughout these stubs. The siblingnextmethods are left unannotated exactly as they were.stubtest does not compare return types, which is why this was invisible. It reports the same single pre-existing error before and after (
ldap3.protocol.sasl.kerberosrequires the optional gssapi package), mypy reports the same 25 pre-existing pyasn1 import errors in both cases, and pyright, ruff and black are clean.