Release/v0.4.1 #1
2 changed files with 15 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ from .bindable import Bindable
|
||||||
from .chain import chain
|
from .chain import chain
|
||||||
from .combine import combine
|
from .combine import combine
|
||||||
from .concat import concat
|
from .concat import concat
|
||||||
|
from .cond import cond
|
||||||
from .const import const
|
from .const import const
|
||||||
from .filter import filter # noqa: W0622 # pylint: disable=W0622
|
from .filter import filter # noqa: W0622 # pylint: disable=W0622
|
||||||
from .map import map # noqa: W0622 # pylint: disable=W0622
|
from .map import map # noqa: W0622 # pylint: disable=W0622
|
||||||
|
|
@ -18,6 +19,7 @@ __all__ = [
|
||||||
"chain",
|
"chain",
|
||||||
"combine",
|
"combine",
|
||||||
"concat",
|
"concat",
|
||||||
|
"cond",
|
||||||
"const",
|
"const",
|
||||||
"filter",
|
"filter",
|
||||||
"map",
|
"map",
|
||||||
|
|
|
||||||
13
src/snakia/core/rx/cond.py
Normal file
13
src/snakia/core/rx/cond.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
from typing import Callable
|
||||||
|
|
||||||
|
|
||||||
|
def cond[**P, T, F](
|
||||||
|
|
|||||||
|
condition: Callable[P, bool],
|
||||||
|
if_true: Callable[P, T],
|
||||||
|
if_false: Callable[P, F],
|
||||||
|
) -> Callable[P, T | F]:
|
||||||
|
return lambda *args, **kw: (
|
||||||
|
if_true(*args, **kw)
|
||||||
|
if condition(*args, **kw)
|
||||||
|
else if_false(*args, **kw)
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue
🚫 Codacy found a high ErrorProne issue: expected '(' (F999)
The issue reported by the Prospector linter is due to the incorrect syntax used for the type parameters in the function definition. In Python's type hinting, you cannot use square brackets
[]for defining type variables; instead, you should use parentheses()with theTypeVarfunction from thetypingmodule.To fix the issue, you need to change the definition of the
condfunction to useTypeVarfor the type parameters. Here's the single line change needed:This comment was generated by an experimental AI tool.