Skip to content

Commit 0ce2a26

Browse files
committed
refactor: renamed optional_of to maybe and as_optional to optional
1 parent 393567f commit 0ce2a26

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

packages/stdlibx-option/src/stdlibx/option/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
zipped,
2222
)
2323
from stdlibx.option._option import (
24-
as_optional,
2524
is_none,
2625
is_some,
26+
maybe,
2727
nothing,
28-
optional_of,
28+
optional,
2929
some,
3030
)
3131

@@ -35,7 +35,6 @@
3535
"OptionUnwrapError",
3636
"and_",
3737
"and_then",
38-
"as_optional",
3938
"collect",
4039
"collect_all",
4140
"expect",
@@ -49,8 +48,9 @@
4948
"map_",
5049
"map_or",
5150
"map_or_else",
51+
"maybe",
5252
"nothing",
53-
"optional_of",
53+
"optional",
5454
"or_",
5555
"or_else",
5656
"some",

packages/stdlibx-option/src/stdlibx/option/_option.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ def is_none(opt: Option[T]) -> TypeIs[Nothing]:
3232
return opt.is_none()
3333

3434

35-
def optional_of(
36-
func: Callable[P, T | None], *args: P.args, **kwargs: P.kwargs
37-
) -> Option[T]:
35+
def maybe(func: Callable[P, T | None], *args: P.args, **kwargs: P.kwargs) -> Option[T]:
3836
value = func(*args, **kwargs)
3937
if value is None:
4038
return nothing()
4139
return some(value)
4240

4341

44-
def as_optional(func: Callable[P, T | None]) -> Callable[P, Option[T]]:
42+
def optional(func: Callable[P, T | None]) -> Callable[P, Option[T]]:
4543
@wraps(func)
4644
def _wrapped(*args: P.args, **kwargs: P.kwargs) -> Option[T]:
4745
result = func(*args, **kwargs)

0 commit comments

Comments
 (0)