Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept dictionary default value for env.dict #76

merged 2 commits into from May 16, 2019


None yet
2 participants
Copy link

commented May 15, 2019

Currently, env.list accepts a list default value, so the following code works:

>>> my_list = env.list("LIST", ["1", "2"])

However, env.dict does not accept a dict default value, so the following code crashes:

>>> my_dict = env.dict("DICT", {"key1": "1", "key2": "2"})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../site-packages/", line 54, in method
    value = preprocess(value, subcast=subcast, **kwargs)
  File ".../site-packages/", line 114, in _preprocess_dict
    for key, val in (item.split("=") for item in value.split(",") if value)
AttributeError: 'dict' object has no attribute 'split'

This lack of similarity between the APIs is somewhat confusing, so this pull request proposes a change that makes env.dict accept a dictionary as default argument.


This comment has been minimized.

Copy link

commented May 16, 2019


@sloria sloria merged commit 4735a40 into sloria:master May 16, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

@c-w c-w deleted the c-w:accept-dict-default-value branch May 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.