Open MobiusIQ opened 7 years ago
I also just discovered that Click tries to convert the default value in parameters twice. The documentation suggests that we need to check the type of passed value to skip over or perform conversion, but this may not be feasible in some cases, such as passing a JSON string literal for a JSON parameter type, because it is indistinguishable based on type and there are edge cases like strings of escaped strings, etc. refs) https://github.com/lablup/backend.ai-client-py/pull/180
So I think the documentation should also mention this behavior and let people implement a ratchet like me, or make changes in the Click side. Note that, when using a ratchet attribute in the ParamType instance, the parameter definitions should instantiate the custom ParamType objects individually instead of reusing one singleton.
@achimnol @MobiusIQ We are happy to have a documentation PR into stable for either of these issues if they are still relevant.
First, awesome project! Using click has been a breeze and the docs have been very helpful!
Relates to the "Implementing custom types" section in the docs: http://click-docs-cn.readthedocs.io/zh_CN/latest/parameters.html
Thought this was a bug at first, but when creating a simple example project, I realized its more of a minor omission in the docs.
When describing how to make custom types, it is not mentioned that defaults should be specified as a string, not as the expected final type.
Consider the following example:
results: