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

Remove required argument from parser methods #403

Merged
merged 1 commit into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Changes:

- _Backwards-incompatible_: `recurse`, `verbose`, `override`,
and `return_path` parameters to `Env.read_env` are now keyword-only.
- _Backwards-incompatible_: The `required` argument to parser methods
is removed. Call a parser method without a default value to make it required.

## 14.1.0 (2025-01-10)

Expand Down
3 changes: 0 additions & 3 deletions src/environs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def method(
| typing.Iterable[typing.Callable[[typing.Any], typing.Any]]
| None
) = None,
required: bool = False,
# Additional kwargs are passed to Field constructor
**kwargs,
) -> _T | None:
Expand All @@ -98,7 +97,6 @@ def method(
):
field = field_or_factory(
validate=validate,
required=required,
load_default=load_default,
**kwargs,
)
Expand All @@ -107,7 +105,6 @@ def method(
field = typing.cast(FieldFactory, field_or_factory)(
subcast=parsed_subcast,
validate=validate,
required=required,
load_default=load_default,
)
parsed_key, value, proxied_key = self._get_from_environ(name, default=Ellipsis)
Expand Down
3 changes: 1 addition & 2 deletions src/environs/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@


class BaseMethodKwargs(typing.TypedDict, total=False):
# Subset of relevant marshmallow.Field kwargs shared by all parser methods
# Relevant marshmallow.Field kwargs shared by all parser methods
validate: (
typing.Callable[[typing.Any], typing.Any]
| typing.Iterable[typing.Callable[[typing.Any], typing.Any]]
| None
)
required: bool


class FieldMethod(typing.Generic[T]):
Expand Down
Loading