refactor
This commit is contained in:
parent
df09fd5a99
commit
f639fc97f9
4 changed files with 14 additions and 14 deletions
|
|
@ -4,7 +4,7 @@ from ytdl_sub.script.types.array import Array
|
|||
from ytdl_sub.script.types.array import ResolvedArray
|
||||
from ytdl_sub.script.types.resolvable import Integer
|
||||
from ytdl_sub.script.types.resolvable import Lambda
|
||||
from ytdl_sub.script.types.resolvable import Lambda2
|
||||
from ytdl_sub.script.types.resolvable import LambdaTwo
|
||||
from ytdl_sub.script.types.resolvable import Resolvable
|
||||
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ class ArrayFunctions:
|
|||
return ResolvedArray([ResolvedArray([val]) for val in array.value])
|
||||
|
||||
@staticmethod
|
||||
def array_enumerate(array: Array, lambda_function: Lambda2) -> Array:
|
||||
def array_enumerate(array: Array, lambda_function: LambdaTwo) -> Array:
|
||||
"""
|
||||
Apply a lambda function on every element in the Array, where each arg
|
||||
passed to the lambda function is ``idx, element`` as two separate args.
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ from ytdl_sub.script.types.resolvable import AnyArgument
|
|||
from ytdl_sub.script.types.resolvable import Boolean
|
||||
from ytdl_sub.script.types.resolvable import Hashable
|
||||
from ytdl_sub.script.types.resolvable import Integer
|
||||
from ytdl_sub.script.types.resolvable import Lambda2
|
||||
from ytdl_sub.script.types.resolvable import Lambda3
|
||||
from ytdl_sub.script.types.resolvable import LambdaThree
|
||||
from ytdl_sub.script.types.resolvable import LambdaTwo
|
||||
from ytdl_sub.script.utils.exceptions import KeyDoesNotExistRuntimeException
|
||||
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ class MapFunctions:
|
|||
# pylint: disable=unused-argument
|
||||
|
||||
@staticmethod
|
||||
def map_apply(mapping: Map, lambda_function: Lambda2) -> Array:
|
||||
def map_apply(mapping: Map, lambda_function: LambdaTwo) -> Array:
|
||||
"""
|
||||
Apply a lambda function on the Map, where each arg
|
||||
passed to the lambda function is ``key, value`` as two separate args.
|
||||
|
|
@ -46,7 +46,7 @@ class MapFunctions:
|
|||
return ResolvedArray([ResolvedArray([key, value]) for key, value in mapping.value.items()])
|
||||
|
||||
@staticmethod
|
||||
def map_enumerate(mapping: Map, lambda_function: Lambda3) -> Array:
|
||||
def map_enumerate(mapping: Map, lambda_function: LambdaThree) -> Array:
|
||||
"""
|
||||
Apply a lambda function on the Map, where each arg
|
||||
passed to the lambda function is ``idx, key, value`` as three separate args.
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class Lambda(Resolvable):
|
|||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Lambda2(Lambda):
|
||||
class LambdaTwo(Lambda):
|
||||
"""
|
||||
Type-hinting for functions that apply lambdas with two inputs per element
|
||||
"""
|
||||
|
|
@ -179,7 +179,7 @@ class Lambda2(Lambda):
|
|||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Lambda3(Lambda):
|
||||
class LambdaThree(Lambda):
|
||||
"""
|
||||
Type-hinting for functions that apply lambdas with three inputs per element
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ from ytdl_sub.script.types.resolvable import Argument
|
|||
from ytdl_sub.script.types.resolvable import BuiltInFunctionType
|
||||
from ytdl_sub.script.types.resolvable import FunctionType
|
||||
from ytdl_sub.script.types.resolvable import Lambda
|
||||
from ytdl_sub.script.types.resolvable import Lambda2
|
||||
from ytdl_sub.script.types.resolvable import Lambda3
|
||||
from ytdl_sub.script.types.resolvable import LambdaThree
|
||||
from ytdl_sub.script.types.resolvable import LambdaTwo
|
||||
from ytdl_sub.script.types.resolvable import NamedType
|
||||
from ytdl_sub.script.types.resolvable import Resolvable
|
||||
from ytdl_sub.script.types.variable import Variable
|
||||
|
|
@ -162,10 +162,10 @@ class FunctionSpec:
|
|||
|
||||
@property
|
||||
def is_lambda_function(self) -> Optional[Type[TLambda]]:
|
||||
if Lambda3 in (self.args or []):
|
||||
return Lambda3
|
||||
if Lambda2 in (self.args or []):
|
||||
return Lambda2
|
||||
if LambdaThree in (self.args or []):
|
||||
return LambdaThree
|
||||
if LambdaTwo in (self.args or []):
|
||||
return LambdaTwo
|
||||
if Lambda in (self.args or []):
|
||||
return Lambda
|
||||
return None
|
||||
|
|
|
|||
Loading…
Reference in a new issue