Document type auto-conversion and test set and frozenset - #3808
Conversation
set and frozenset types in public APIset and frozenset types in public API
|
For 1, it should probably read "If no type is provided, the type of the default value is used if it's recognized, otherwise Or it might have been trying to describe the current behavior, and been a little vague. "If no type is provided, the type of the default is used directly, rather than applying a Click param type. This can lead to unexpected behavior when passing the string value to the type constructor, such as |
|
For 2, I do not want to add comma splitting to the core behavior. It's maybe appropriate for a type, but not auto detected, and I'm not sure it needs to be in core at all. It's also very easy for users to misunderstand, if they type |
f423c16 to
9b9596f
Compare
|
Thanks @davidism for the feedback. For point 1, I agree it is a documentation issue. Even your answer is not really clear. So instead of trying to generalize the paragraph, I went with an exhaustive list of values and how they're interpreted by Click. See my updated documentation in the PR. For point 2, yes, I was pointing to the So all in all, I propose to make this PR a documentation fix that is also freezing the current Click behavior with unittests. That way it can reach 8.5.1. |
set and frozenset types in public APIset and frozenset types in public API
set and frozenset types in public APIset and frozenset
9b9596f to
1864be1
Compare
|
I like the docs, and agree with adding tests to cover this behavior. |
|
This looks good. Are you ready for me to merge? |
1864be1 to
394088a
Compare
Yes! I don't like the result of these coverage, but at least it plugs documentation holes and lockdown the current behavior of Click. So this is a net benefits for the project. Let's keep the debate for another day! :) |
This is an ongoing exploration of usage of
setandfrozensettypes in various places in the public API. It addresses the suspicion I had for a long time about inconsistent behavior, as detailed in #3036.These tests for the moment only freeze the current behavior of Click. But reveals inconsistent or awkward behavior that are left to be discussed and decided upon for eventual bug fixes.
A
set,frozensetordictdefault is guessed as aSTRING, not a container type (test_type_from_default_container,test_convert_type_from_container_default). This contradicts the documented rule of "If no type is provided, the type of the default value is used" Should we change that so we guess a container type instead of the currentSTRING?An explicit
type=setortype=frozensetis splitting the value provided to it (seetest_explicit_container_type_splits_string). This looks like a bug we want to fix. My instinct is to split on commas, which overlaps an older discussion at: Allownargs=-1in options with a non-whitespace separator #2771 (comment) and my preference for it. Also dug out an old proposal at: Option value separators #422.Also note that this also affects the envvars as demonstrated by my tests.
Closes #3036.