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

Typing of env.list is always list | None #406

Closed
lucas-bremond opened this issue Feb 10, 2025 · 2 comments
Closed

Typing of env.list is always list | None #406

lucas-bremond opened this issue Feb 10, 2025 · 2 comments
Labels

Comments

@lucas-bremond
Copy link
Contributor

Hi!

Is there any particular reason for the typing of env.list to be list | None even when providing a non-null default?

For example, the code below is valid:

my_list: list[int] | None = env.list(
    "MY_LIST",
    subcast=int,
    default=[],
)

but I believe we should expect my_list to be of type list[int] instead (that'd be consistent with the other types, e.g. env.int("MY_INT", default=123) returning int, etc).

Note that the same behavior is observed for env.dict as well.

Thanks!

@sloria
Copy link
Owner

sloria commented Feb 10, 2025

yeah, this is an issue i've been meaning to fix but haven't had the time. thanks for making an issue. PRs welcome

@sloria sloria added the bug label Feb 10, 2025
@lucas-bremond
Copy link
Contributor Author

Understood, now at least I know you're open for a fix :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants