You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It works as expected when arg is specified with an ordinary command-line option:
$ python3 test.py --arg foo
('foo',)
But when we use an environment variable instead, Click splits the string into characters:
$ TEST_ARG=foo python3 test.py
('f', 'o', 'o')
This is the classic Python iterating-over-a-string-when-you-thought-you-had-a-list failure mode. (These examples were run with click 0.7 from PyPI.)
I can see two reasonable resolutions here: split environment variables on whitespace or don't split them at all. The latter is probably more predictable but the former is more flexible.
The text was updated successfully, but these errors were encountered:
I found a nice way to handle this now. It's the type's responsibility to provide a way to customize this. This means that I can have "foo:bar:baz" for paths and files and "foo bar baz" for everything else. This can also be further customized to even fully disable that feature.
An option with
multiple=True
yields unexpected (i.e., not useful) behavior when it is specified via an environment variable.Here's a simple example script:
It works as expected when
arg
is specified with an ordinary command-line option:But when we use an environment variable instead, Click splits the string into characters:
This is the classic Python iterating-over-a-string-when-you-thought-you-had-a-list failure mode. (These examples were run with click 0.7 from PyPI.)
I can see two reasonable resolutions here: split environment variables on whitespace or don't split them at all. The latter is probably more predictable but the former is more flexible.
The text was updated successfully, but these errors were encountered: