Skip to content

Conversation

@atulk-code
Copy link

Context.lookup_default() is a public API method that users can override or call directly. In Click 8.3.0, commit 1c20dc6 deferred UNSET normalization which caused lookup_default to return the internal UNSET sentinel instead of None when a parameter was not in the default_map.

This broke the public API contract - users expect None, not an internal sentinel object.

This fix:

  • Adds internal _lookup_default() method that returns UNSET for internal use
  • Modifies public lookup_default() to normalize UNSET to None
  • Updates internal callers to use _lookup_default()
  • Adds regression tests to verify the fix

Fixes #3145

Context.lookup_default() is a public API method that users can override
or call directly. In Click 8.3.0, commit 1c20dc6 deferred UNSET
normalization which caused lookup_default to return the internal UNSET
sentinel instead of None when a parameter was not in the default_map.

This broke the public API contract - users expect None, not an internal
sentinel object.

This fix:
- Adds internal _lookup_default() method that returns UNSET for internal use
- Modifies public lookup_default() to normalize UNSET to None
- Updates internal callers to use _lookup_default()
- Adds regression tests to verify the fix

Fixes pallets#3145
@davidism davidism closed this Jan 31, 2026
@davidism davidism reopened this Jan 31, 2026
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.

lookup_default returns Sentinel.UNSET instead of None

2 participants