Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CLI: Fix deduced option type for
DynamicEntryPointCommandGroup
The `type` for the click command options were based of the `annotation` property of the model fields. These annotations can sometimes be compound, however, e.g, `Union[int, float]` and `Optional[str]` but these are not supported by `click.option`. It would more or less work for Python 3.10 and up, but it would except for Python 3.9 because the type would be wrapped in the `click.FuncParamType` which would call `__name__` on the type, but this was only added in Python 3.10. The solution is to extract the arguments in case of a compound type. The `typing.get_args()` method does just this. If the annotation is a plain type, it simply returns an empty tuple.
- Loading branch information