Skip to content

Comments

Hide Sentinel.UNSET values as None in lookup_default()#3224

Open
kdeldycke wants to merge 1 commit intopallets:mainfrom
kdeldycke:hide-unset-in-lookup_default
Open

Hide Sentinel.UNSET values as None in lookup_default()#3224
kdeldycke wants to merge 1 commit intopallets:mainfrom
kdeldycke:hide-unset-in-lookup_default

Conversation

@kdeldycke
Copy link
Collaborator

This PR address issue #3145, in which the UNSET sentinel is leaking into lookup_default() when users have overriding it.

This changes prevent lookup_default() to return UNSET as-is, and masquerade it as None. To account for this change in lookup_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.

@kdeldycke kdeldycke added this to the 8.3.2 milestone Feb 20, 2026
@kdeldycke kdeldycke added bug f:parameters feature: input parameter types labels Feb 20, 2026
@kdeldycke kdeldycke force-pushed the hide-unset-in-lookup_default branch from fe2f919 to 2112621 Compare February 20, 2026 08:31
@kdeldycke kdeldycke linked an issue Feb 20, 2026 that may be closed by this pull request
@kdeldycke
Copy link
Collaborator Author

kdeldycke commented Feb 20, 2026

This PR replace AI-slop from: #3199, #3202, #3209, #3212 and #3215.

@kdeldycke kdeldycke force-pushed the hide-unset-in-lookup_default branch from 2112621 to aaf99a3 Compare February 20, 2026 08:52
@kdeldycke
Copy link
Collaborator Author

Also note that the unnatural None dance around the results of lookup_default were made to please mypy.

@davidism
Copy link
Member

davidism commented Feb 20, 2026

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.

@kdeldycke
Copy link
Collaborator Author

@Rowlando13, should we merge? to main or stable?

@Rowlando13
Copy link
Collaborator

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.

@Rowlando13
Copy link
Collaborator

9.0 should be next release.

@Rowlando13 Rowlando13 modified the milestones: 8.3.2, 9.0.0 Feb 20, 2026
@kdeldycke
Copy link
Collaborator Author

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. 😁

kdeldycke added a commit to kdeldycke/click-extra that referenced this pull request Feb 21, 2026
@kdeldycke
Copy link
Collaborator Author

FYI, just tested this fix against my own Click Extra codebase and could not find any regression: kdeldycke/click-extra@4bbd387

@kdeldycke kdeldycke modified the milestones: 9.0.0, 8.3.2 Feb 21, 2026
@Rowlando13
Copy link
Collaborator

Sounds good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug f:parameters feature: input parameter types

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lookup_default returns Sentinel.UNSET instead of None

3 participants