fix: lookup_default returns None instead of UNSET sentinel#3199
fix: lookup_default returns None instead of UNSET sentinel#3199atulk-code wants to merge 1 commit intopallets:mainfrom
Conversation
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
|
This looks a bit AI-generated. Don't know what pallets policy is on that front. In the mean time @atulk-code, can you confirm or deny it? As for the solution, it is not bad. But the problem is adding a private You should add a unittest that is reproducing #3145 exactly, with its custom |
|
This is like the 6th person to AI generate this PR. I'm not interested in that. |
|
I'm back from other rabbit holes so I'll try to get back to work on Click. I guess I can fix that for good based on my feedback. |
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:
Fixes #3145