Skip to content

fix(ldap.sasl): allow None in SASL callback values type annotation - #654

Open
spaceone wants to merge 1 commit into
python-ldap:mainfrom
spaceone:refactor/sasl-authzid
Open

spaceone wants to merge 1 commit into
python-ldap:mainfrom
spaceone:refactor/sasl-authzid

Conversation

@spaceone

Copy link
Copy Markdown
Contributor

it's allowed to pass values e.g. authzid/authcid as None, which will default to the SASL default value or an empty string:

cb_result: Union[str, bytes] | None = self.cb_value_dict.get(cb_id)
if cb_result is None:
    cb_result = defresult or ''

Issue #368

@spaceone

Copy link
Copy Markdown
Contributor Author

Feel free to reject. I will adjust all callers then, that only empy strings are passed instead.

@mistotebe

Copy link
Copy Markdown
Contributor

You'd have to change it to Mapping to let the concrete implementations pass typecheck, but including None in the passed dict sounds strange so I think I'd prefer you passed '' as empty or better just not passed those in at all? It's not a -1 from me, more like a question mark. I'll let @droideck weigh in as well

@spaceone
spaceone force-pushed the refactor/sasl-authzid branch 2 times, most recently from 79353e4 to eb43064 Compare October 19, 2026 10:55
Update the SASL callback value type annotation to also accept bytes
and None, reflecting the values supported by the existing
callback implementation.

SASL callback values such as `authzid` and `authcid` may be None,
in which case the callback falls back to the SASL-provided default
value or an empty string.

Additionally, byte strings are valid callback values and should
be accepted without requiring conversion to str.

Issue python-ldap#368
@spaceone
spaceone force-pushed the refactor/sasl-authzid branch from eb43064 to 0523b3f Compare October 19, 2026 21:58
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.

2 participants