Skip to content

Commit cb6bfcc

Browse files
authored
Fix curried function docstrings (#236)
1 parent 6f6bc59 commit cb6bfcc

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,12 @@ assert xs is Nothing
319319

320320
### Option as an applicative
321321

322-
In functional programming, we sometimes want to combine two Option values into a new Option. However, this combination should only happen if both Options are Some. If either Option is None, the resulting value should also be None.
322+
In functional programming, we sometimes want to combine two Option values into a new Option. However, this combination
323+
should only happen if both Options are Some. If either Option is None, the resulting value should also be None.
323324

324-
The map2 function allows us to achieve this behavior. It takes two Option values and a function as arguments. The function is applied only if both Options are Some, and the result becomes the new Some value. Otherwise, map2 returns None.
325+
The map2 function allows us to achieve this behavior. It takes two Option values and a function as arguments. The
326+
function is applied only if both Options are Some, and the result becomes the new Some value. Otherwise, map2 returns
327+
None.
325328

326329
This approach ensures that our combined value reflects the presence or absence of data in the original Options.
327330

@@ -414,7 +417,7 @@ type union `(A | B)` are both types, while the cases in a tagged union type `U =
414417
are both constructors for the type U and are not types themselves. One consequence is
415418
that tagged unions can be nested in a way union types might not.
416419

417-
In Expression you make a tagged union by defining your type similar to a dataclass and
420+
In Expression you make a tagged union by defining your type similar to a `dataclass` and
418421
decorate it with `@tagged_union` and add the appropriate generic types that this union
419422
represent for each case. Then you optionally define static or class-method constructors
420423
for creating each of the tagged union cases.
@@ -456,7 +459,7 @@ check correctly when pattern matching. The `tag` field if specified should be a
456459
type with all the possible values for the tag. This is used by static type checkers to
457460
check exhaustiveness of pattern matching.
458461

459-
Each case is given the `case()` field initializer. This is optioal, but recommended for
462+
Each case is given the `case()` field initializer. This is optional, but recommended for
460463
static type checkers to work correctly. It's not required for the code to work properly,
461464

462465
Now you may pattern match the shape to get back the actual value:

expression/core/curry.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import functools
12
from collections.abc import Callable
23
from typing import Any, Concatenate, Literal, TypeVar, overload
34

@@ -102,7 +103,7 @@ def curry(num_args: _Arity) -> Callable[..., Any]:
102103
"""
103104

104105
def wrapper(fun: Callable[..., Any]) -> Callable[..., Any]:
105-
return _curry((), num_args + 1, fun)
106+
return functools.wraps(fun)(_curry((), num_args + 1, fun))
106107

107108
return wrapper
108109

@@ -192,6 +193,7 @@ def curry_flip(
192193
"""
193194

194195
def _wrap_fun(fun: Callable[..., Any]) -> Callable[..., Any]:
196+
@functools.wraps(fun)
195197
def _wrap_args(*args: Any, **kwargs: Any) -> Callable[..., Any]:
196198
def _wrap_curried(*curry_args: Any) -> Any:
197199
return fun(*curry_args, *args, **kwargs)

0 commit comments

Comments
 (0)