-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix get_parameter_source() during type conversion and eager callbacks #3484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2609,6 +2609,11 @@ def handle_parse_result( | |
| with augment_usage_errors(ctx, param=self): | ||
| value, source = self.consume_value(ctx, opts) | ||
|
|
||
| # Record the source before processing so eager callbacks and type | ||
| # conversion can inspect it. Restored after arbitration if this | ||
| # option loses a feature-switch group. | ||
| ctx.set_parameter_source(self.name, source) | ||
|
|
||
| # Display a deprecation warning if necessary. | ||
| if ( | ||
| self.deprecated | ||
|
|
@@ -2654,14 +2659,13 @@ def handle_parse_result( | |
| ) | ||
|
|
||
| if is_winner: | ||
| ctx.set_parameter_source(self.name, source) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Winner already has the right source from the early write. Only params need updating here. |
||
| if self.expose_value: | ||
| ctx.params[self.name] = value | ||
| ctx._param_default_explicit[self.name] = self._default_explicit | ||
| elif existing_source is None: | ||
| # Nothing has claimed the slot yet. Record at least our source so downstream | ||
| # lookups don't return ``None``. | ||
| ctx.set_parameter_source(self.name, source) | ||
| elif existing_source is not None: | ||
| # Lost arbitration; restore the winning option's source. | ||
| ctx.set_parameter_source(self.name, existing_source) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This option already wrote its provisional source above; if it loses arbitration, put the winner’s source back so |
||
| # else: keep the provisional source recorded before process_value. | ||
|
|
||
| return value, args | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restores 8.3.3 timing so
get_parameter_source()works inside convert / eager callbacks (#3458).#3404 moved this to the end of
handle_parse_result, which caused the regression.