sloria / environs

simplified environment variable parsing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistent behavior with `env.list`

lucas-bremond opened this issue · comments

commented

When MY_ENV_VAR is not defined,

env.int("MY_ENV_VAR", default=None)

returns None (as expected), but:

env.list("MY_ENV_VAR", subcast=str, default=None)

yields the following Exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/site-packages/environs/__init__.py", line 122, in method
    value = preprocess(value, **preprocess_kwargs)
  File "/usr/local/lib/python3.10/site-packages/environs/__init__.py", line 206, in _preprocess_list
    return typing.cast(str, value).split(delimiter) if value != "" else []
AttributeError: 'NoneType' object has no attribute 'split'

I believe the second example should return None as well.

Thoughts?

thanks for reporting this! this is fixed in #316