Skip to content

Comments

Fix callable flag_value being instantiated when used as a default#3225

Open
kdeldycke wants to merge 1 commit intopallets:mainfrom
kdeldycke:keep-classes-flag-values-uninstanciated
Open

Fix callable flag_value being instantiated when used as a default#3225
kdeldycke wants to merge 1 commit intopallets:mainfrom
kdeldycke:keep-classes-flag-values-uninstanciated

Conversation

@kdeldycke
Copy link
Collaborator

This fix issue #3121, where a flag_value set to a class produce an instance of that class in the particular case that it is explicitly set as the default.

The fix consist in lazily resolving the default value at the time of use, with a branch dedicated to callables.

I extended the unittests to default_map to demonstrate the current state of callable presence in them.

@kdeldycke
Copy link
Collaborator Author

This PR replace AI-slop from: #3201 and #3213

@kdeldycke kdeldycke force-pushed the keep-classes-flag-values-uninstanciated branch from ead2d43 to 75d0590 Compare February 21, 2026 14:15
@kdeldycke kdeldycke added this to the 8.3.2 milestone Feb 21, 2026
@kdeldycke kdeldycke added bug f:parameters feature: input parameter types labels Feb 21, 2026
@kdeldycke kdeldycke force-pushed the keep-classes-flag-values-uninstanciated branch from 90ea873 to d898d6c Compare February 21, 2026 14:16
@kdeldycke kdeldycke force-pushed the keep-classes-flag-values-uninstanciated branch from d898d6c to de48f5d Compare February 21, 2026 14:27
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.

Using a class as a flag_value causes the default to be instantiated in click 8.3.0

1 participant