Hide Sentinel.UNSET values as None in lookup_default()#3224
Hide Sentinel.UNSET values as None in lookup_default()#3224Rowlando13 merged 2 commits intopallets:stablefrom
Sentinel.UNSET values as None in lookup_default()#3224Conversation
fe2f919 to
2112621
Compare
2112621 to
aaf99a3
Compare
|
Also note that the unnatural |
|
This is fine for the bug fix, but you're right that this is getting messy. We need to figure out a long term solution. |
|
@Rowlando13, should we merge? to |
|
Main. @kdeldycke Getting this fix is good, but it would be better if we try to make larger fixes to simplify the issues Click has accumulated. |
|
9.0 should be next release. |
|
Looks like @davidism is in favor on Discord of getting 8.3.2 out first, which could include this fix, which as limited blast radius. 😁 |
|
FYI, just tested this fix against my own Click Extra codebase and could not find any regression: kdeldycke/click-extra@4bbd387 |
|
Sounds good. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
|
Thanks @Rowlando13 for the merge! |
This is a reasonable assumption as in dict, you can materialize the absence of value by the absence of the key. But even if @sankarcn is a bot, it can still point to a gap in the tests around |
|
@kdeldycke I am a human. Sorry, I could not reply to you and considered your reply as a guidance and I did not have anything to add. This was one of the edge cases, I came across when testing the PR, for a different purpose. |
Ahah sorry, paranoia is high these days among open-source maintainers. Maybe you can tell us more about this use case. If you stumble upon it, there is a high chance others will. So I'd like to make a case so we can reduce the blast-radius of |
This PR address issue #3145, in which the
UNSETsentinel is leaking intolookup_default()when users have overriding it.This changes prevent
lookup_default()to returnUNSETas-is, and masquerade it asNone. To account for this change inlookup_default()behavior, I had to update some internal checks around defaults.Additionally, to prevent any side-effects, I added a couple of tests to fill the gaps in coverage of
lookup_default(), especially around treatment of absence of value and value of absence.Important
I did use LLMs (Claude Opus 4.6) in the process of creating this PR, but as a co-worker to criticize my changes and modifications, not as a vibe-coding agent. This PR was carefully written, edited and reviewed by me.