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

Inconsistent behavior with env.list #298

Closed
lucas-bremond opened this issue Aug 22, 2023 · 1 comment · Fixed by #316
Closed

Inconsistent behavior with env.list #298

lucas-bremond opened this issue Aug 22, 2023 · 1 comment · Fixed by #316
Labels

Comments

@lucas-bremond
Copy link

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?

@sloria
Copy link
Owner

sloria commented Jan 11, 2024

thanks for reporting this! this is fixed in #316

@sloria sloria added the bug label Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants