Skip to content

Commit

Permalink
Remove required argument from parser methods (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria authored Jan 23, 2025
1 parent 051f36b commit f460dbe
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
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

0 comments on commit f460dbe

Please sign in to comment.