refactor: merge side.py and calls.py to funcs.py
This commit is contained in:
parent
420f7626fb
commit
3d132251fc
3 changed files with 10 additions and 14 deletions
|
|
@ -1,10 +1,9 @@
|
||||||
from .attrs import get_attrs, get_or_set_attr
|
from .attrs import get_attrs, get_or_set_attr
|
||||||
from .calls import call, caller
|
from .funcs import call, caller, side, side_func
|
||||||
from .exceptions import catch, throw
|
from .exceptions import catch, throw
|
||||||
from .frames import frame
|
from .frames import frame
|
||||||
from .gil import GIL_ENABLED, nolock
|
from .gil import GIL_ENABLED, nolock
|
||||||
from .inherit import inherit
|
from .inherit import inherit
|
||||||
from .side import side, side_func
|
|
||||||
from .this import this
|
from .this import this
|
||||||
from .to_async import to_async
|
from .to_async import to_async
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Callable, ParamSpec, TypeVar
|
from typing import Any, Callable, ParamSpec, TypeVar
|
||||||
|
|
||||||
P = ParamSpec("P")
|
P = ParamSpec("P")
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
|
|
@ -10,3 +10,11 @@ def call(f: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> T:
|
||||||
|
|
||||||
def caller(f: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> Callable[..., T]:
|
def caller(f: Callable[P, T], *args: P.args, **kwargs: P.kwargs) -> Callable[..., T]:
|
||||||
return lambda *_, **__: f(*args, **kwargs)
|
return lambda *_, **__: f(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def side(value: T, *_: Any, **__: Any) -> T:
|
||||||
|
return value
|
||||||
|
|
||||||
|
|
||||||
|
def side_func(value: T, *_: Any, **__: Any) -> Callable[..., T]:
|
||||||
|
return lambda *_, **__: value
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
from typing import Any, Callable, TypeVar
|
|
||||||
|
|
||||||
T = TypeVar("T")
|
|
||||||
|
|
||||||
|
|
||||||
def side(value: T, *_: Any, **__: Any) -> T:
|
|
||||||
return value
|
|
||||||
|
|
||||||
|
|
||||||
def side_func(value: T, *_: Any, **__: Any) -> Callable[..., T]:
|
|
||||||
return lambda *_, **__: value
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue