get_click_type
Determines and returns the appropriate click.ParamType based on a provided type annotation and parameter metadata. It maps standard Python types, Enums, and Literals to Click-compatible types, including support for ranges, files, and custom parsers.
def get_click_type(
annotation: Any,
parameter_info: ParameterInfo
) - > click.ParamType
Determines the appropriate Click parameter type based on a Python type annotation and additional parameter metadata. This function maps standard Python types, Enums, and file-like objects to their corresponding Click validation and conversion logic.
Parameters
| Name | Type | Description |
|---|---|---|
| annotation | Any | The Python type hint or class used to infer the base Click data type (e.g., int, str, Path, or Enum). |
| parameter_info | ParameterInfo | An object containing metadata such as min/max ranges, file permissions, date formats, and custom parsers that refine the Click type configuration. |
Returns
| Type | Description |
|---|---|
click.ParamType | A Click parameter type instance configured with validation constraints like ranges, file modes, or choice sets. |