Fix mypy type handling in partial function and add regression tests · dry-python/returns@311c13a · GitHub
Skip to content

Commit 311c13a

Browse files
committed
Fix mypy type handling in partial function and add regression tests
1 parent ff4b2d4 commit 311c13a

4 files changed

Lines changed: 107 additions & 75 deletions

File tree

‎returns/contrib/mypy/_features/partial.py‎

Lines changed: 5 additions & 0 deletions

‎returns/curry.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def partial(
11-
func: Callable[..., _ReturnType],
11+
func: Callable[..., _ReturnType] | None = None,
1212
*args: Any,
1313
**kwargs: Any,
1414
) -> Callable[..., _ReturnType]:
@@ -35,6 +35,13 @@ def partial(
3535
- https://docs.python.org/3/library/functools.html#functools.partial
3636
3737
"""
38+
if func is None:
39+
def _decorator( # type: ignore[return-type]
40+
inner: Callable[..., _ReturnType],
41+
) -> Callable[..., _ReturnType]:
42+
return _partial(inner, *args, **kwargs)
43+
44+
return _decorator
3845
return _partial(func, *args, **kwargs)
3946

4047

‎typesafety/test_curry/test_partial/test_partial.py‎

Lines changed: 0 additions & 74 deletions
This file was deleted.

‎typesafety/test_curry/test_partial/test_partial.yml‎

Lines changed: 94 additions & 0 deletions

0 commit comments

Comments
 (0)