Skip to content

Commit

Permalink
Default not fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
DeviousStoat committed Mar 3, 2024
1 parent c0f0915 commit 750d888
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/pydash/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ def apply_if_not_none(obj: t.Optional[T], func: t.Callable[[T], T2]) -> t.Option

@t.overload
def apply_ignore_excs(
obj: T, func: t.Callable[[T], T2], exceptions: t.Iterable[t.Type[Exception]], fallback: T3
obj: T, func: t.Callable[[T], T2], exceptions: t.Iterable[t.Type[Exception]], default: T3
) -> t.Union[T2, T3]:
...

Expand All @@ -1405,24 +1405,24 @@ def apply_ignore_excs(
obj: T,
func: t.Callable[[T], T2],
exceptions: t.Iterable[t.Type[Exception]],
fallback: Unset = UNSET,
default: Unset = UNSET,
) -> t.Union[T, T2]:
...


def apply_ignore_excs(obj, func, exceptions, fallback=UNSET):
def apply_ignore_excs(obj, func, exceptions, default=UNSET):
"""
Tries to apply `func` to `obj` if any of the exceptions in `excs` are raised, return `fallback`
Tries to apply `func` to `obj` if any of the exceptions in `excs` are raised, return `default`
or `obj` if not set.
Args:
obj: Object to apply `func` to.
func: Function to apply to `obj`.
excs: Exceptions to catch.
fallback: Value to return if exception is raised.
default: Value to return if exception is raised.
Returns:
Result of applying `func` to `obj` or ``fallback``.
Result of applying `func` to `obj` or ``default``.
Example:
Expand All @@ -1438,7 +1438,7 @@ def apply_ignore_excs(obj, func, exceptions, fallback=UNSET):
try:
return func(obj)
except tuple(exceptions):
return obj if fallback is UNSET else fallback
return obj if default is UNSET else default


@t.overload
Expand Down

0 comments on commit 750d888

Please sign in to comment.