Skip to content

ldap3: add types for Connection.unbind - #16243

Open
MaicoTimmerman wants to merge 1 commit into
python:mainfrom
MaicoTimmerman:ldap3-connection-unbind
Open

ldap3: add types for Connection.unbind#16243
MaicoTimmerman wants to merge 1 commit into
python:mainfrom
MaicoTimmerman:ldap3-connection-unbind

Conversation

@MaicoTimmerman

@MaicoTimmerman MaicoTimmerman commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This PR adds types for Connection.unbind's controls argument, and propagates the types that become known from there to protocol.convert.build_controls_list and the BaseStrategy.send set of subclasses that unbind feeds its controls into.

Rationale for the types:

  • controls is a _ControlSequence | None. build_controls_list rejects anything that is not in SEQUENCE_TYPES (set, list, tuple, generator, dict_keys), so the alias enumerates those rather than using Iterable, mirroring the existing _ServerSequence alias. Items are a Control object or a (controlType, criticality, controlValue) triple, the two forms build_controls_list accepts.
  • The alias lives in protocol.convert next to build_controls_list, the function that defines the contract, and is imported by core.connection and the strategies.
  • build_controls_list returns Controls | None; it returns None for both None and an empty sequence.
  • unbind returns Literal[True] | tuple[...]: it hands a hardcoded True to _prepare_return_value, which returns that status directly, except on the thread-safe strategies (SAFE_SYNC, SAFE_RESTARTABLE), where it returns a
    (status, result, response, request) tuple.
  • The result, response and request members of that tuple use new _Result, _Response and _Request placeholder aliases, also used for the matching Connection attributes. Their real types are per-operation dicts, which is left for a follow-up.

Written with the help of Factory Droid (Opus 5), humanly curated.

Co-Authored-By: Factory Droid (Opus 5)
@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant