Skip to content

Fix #3145: lookup_default returns Sentinel.UNSET instead of None#3215

Closed
rodionsteshenko wants to merge 1 commit intopallets:mainfrom
rodionsteshenko:fix-issue-3145
Closed

Fix #3145: lookup_default returns Sentinel.UNSET instead of None#3215
rodionsteshenko wants to merge 1 commit intopallets:mainfrom
rodionsteshenko:fix-issue-3145

Conversation

@rodionsteshenko
Copy link
Copy Markdown

Fix lookup_default returning the internal Sentinel.UNSET value instead of None when the parameter name is not found in default_map (or when default_map is None). This is a regression introduced in 8.3.0.

Changes

  • Context.lookup_default() now returns None instead of UNSET when the name is not in the default map or when there is no default map
  • Updated internal callers in Parameter.get_default() and Parameter.consume_value() to check for None instead of UNSET since lookup_default no longer leaks the sentinel

Test

Added 4 test cases in test_context.py:

  • test_lookup_default_returns_none_when_not_in_map — verifies None is returned for missing keys
  • test_lookup_default_returns_none_when_no_default_map — verifies None when default_map is None
  • test_lookup_default_returns_value_when_in_map — verifies correct value retrieval
  • test_lookup_default_calls_callable_when_call_true — verifies callable defaults are called

The first two tests reproduce the original bug (fail without the fix, pass with it).

Tested locally on macOS ARM (Apple Silicon). Full test suite passes (1323 passed).

When lookup_default is called and the parameter name is not found in
the default_map (or when default_map is None), the method returned the
internal Sentinel.UNSET value instead of None. This is a regression
introduced in 8.3.0 that breaks downstream code which checks the
return value against None.

Also updated internal callers (get_default, consume_value) to check
for None instead of UNSET since lookup_default no longer leaks the
sentinel.

Fixes pallets#3145
@davidism davidism closed this Feb 17, 2026
@kdeldycke kdeldycke added this to the 8.3.2 milestone Feb 20, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 7, 2026
@Rowlando13 Rowlando13 removed this from the 8.3.2 milestone Mar 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants