#127: Refactored class ParameterFormatters and docstrings#128
Open
#127: Refactored class ParameterFormatters and docstrings#128
ParameterFormatters and docstrings#128Conversation
tkilias
reviewed
Feb 10, 2026
| ctx.params[parameter_name] = param_formatter.format(**kwargs) # type: ignore | ||
| The Click API allows updating customized parameters only in a callback | ||
| function. There is no way to inject them directly into the CLI, see | ||
| https://click.palletsprojects.com/en/stable/api/#click.Command.callback. |
Collaborator
There was a problem hiding this comment.
A callback is the function click is calling for a command. This is nothing special. It is the same as
@command
def my_command(...)
Contributor
Author
There was a problem hiding this comment.
I updated the doc string. Please review again.
| Dynamic formatting for customized Click CLI parameters. | ||
|
|
||
| The idea is that some of the cli parameters can be programmatically customized based | ||
| on values of other parameters and externally supplied formatters. For example a specialized |
Collaborator
There was a problem hiding this comment.
To be honest, the new description is more cryptic than the original one.
Contributor
Author
There was a problem hiding this comment.
I updated the doc string. Please review again.
tkilias
reviewed
Feb 11, 2026
|
|
||
| return source.value | ||
|
|
||
| def set_formatter(self, param_name: str, default_value: str) -> None: |
Collaborator
There was a problem hiding this comment.
Suggested change
| def set_formatter(self, param_name: str, default_value: str) -> None: | |
| def set_formatter(self, destination_parameter: str, format_pattern: str) -> None: |
we can't rename, because this would break the public interface, for this reason we add this information to the docstrings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #127