@@ -518,11 +518,16 @@ def __add__(self, other: Union[float, AbstractList[float]]
518518 :raises TypeError:
519519 """
520520 if isinstance (other , AbstractList ):
521- d_operation : Callable [[Any , float ], float ] = lambda x , y : x + y
522- return DualList (
523- left = self , right = other , operation = d_operation )
521+
522+ def d_operation (x : Any , y : float ) -> float :
523+ return x + y
524+
525+ return DualList (left = self , right = other , operation = d_operation )
524526 if is_number (other ):
525- s_operation : Callable [[Any ], float ] = lambda x : x + other
527+
528+ def s_operation (x : Any ) -> float :
529+ return x + other
530+
526531 return SingleList (a_list = self , operation = s_operation )
527532 raise TypeError ("__add__ operation only supported for other "
528533 "RangedLists and numerical Values" )
@@ -540,11 +545,16 @@ def __sub__(self, other: Union[float, AbstractList[float]]
540545 :raises TypeError:
541546 """
542547 if isinstance (other , AbstractList ):
543- d_operation : Callable [[Any , float ], float ] = lambda x , y : x - y
544- return DualList (
545- left = self , right = other , operation = d_operation )
548+
549+ def d_operation (x : Any , y : float ) -> float :
550+ return x - y
551+
552+ return DualList (left = self , right = other , operation = d_operation )
546553 if is_number (other ):
547- s_operation : Callable [[Any ], float ] = lambda x : x - other
554+
555+ def s_operation (x : Any ) -> float :
556+ return x - other
557+
548558 return SingleList (a_list = self , operation = s_operation )
549559 raise TypeError ("__sub__ operation only supported for other "
550560 "RangedLists and numerical Values" )
@@ -562,11 +572,16 @@ def __mul__(self, other: Union[float, AbstractList[float]]
562572 :raises TypeError:
563573 """
564574 if isinstance (other , AbstractList ):
565- d_operation : Callable [[Any , float ], float ] = lambda x , y : x * y
566- return DualList (
567- left = self , right = other , operation = d_operation )
575+
576+ def d_operation (x : Any , y : float ) -> float :
577+ return x * y
578+
579+ return DualList (left = self , right = other , operation = d_operation )
568580 if is_number (other ):
569- s_operation : Callable [[Any ], float ] = lambda x : x * other
581+
582+ def s_operation (x : Any ) -> float :
583+ return x * other
584+
570585 return SingleList (a_list = self , operation = s_operation )
571586 raise TypeError ("__mul__ operation only supported for other "
572587 "RangedLists and numerical Values" )
@@ -585,13 +600,18 @@ def __truediv__(self, other: Union[float, AbstractList[float]]
585600 :raises TypeError:
586601 """
587602 if isinstance (other , AbstractList ):
588- d_operation : Callable [[Any , float ], float ] = lambda x , y : x / y
589- return DualList (
590- left = self , right = other , operation = d_operation )
603+
604+ def d_operation (x : Any , y : float ) -> float :
605+ return x / y
606+
607+ return DualList (left = self , right = other , operation = d_operation )
591608 if is_number (other ):
592609 if _is_zero (other ):
593610 raise ZeroDivisionError ()
594- s_operation : Callable [[Any ], float ] = lambda x : x / other
611+
612+ def s_operation (x : Any ) -> float :
613+ return x / other
614+
595615 return SingleList (a_list = self , operation = s_operation )
596616 raise TypeError ("__truediv__ operation only supported for other "
597617 "RangedLists and numerical Values" )
@@ -607,19 +627,25 @@ def __floordiv__(self, other: Union[float, AbstractList[float]]
607627 :raises TypeError:
608628 """
609629 if isinstance (other , AbstractList ):
610- d_operation : Callable [[Any , float ], int ] = lambda x , y : int (x // y )
611- return DualList (
612- left = self , right = other , operation = d_operation )
630+
631+ def d_operation (x : Any , y : float ) -> int :
632+ return int (x // y )
633+
634+ return DualList (left = self , right = other , operation = d_operation )
613635 if is_number (other ):
614636 if _is_zero (other ):
615637 raise ZeroDivisionError ()
616- s_operation : Callable [[Any ], int ] = lambda x : int (x / other )
638+
639+ def s_operation (x : Any ) -> int :
640+ return int (x / other )
641+
617642 return SingleList (a_list = self , operation = s_operation )
618- raise TypeError ("__floordiv__ operation only supported for other "
619- "RangedLists and numerical Values" )
643+ raise TypeError (
644+ "__floordiv__ operation only supported for other "
645+ "RangedLists and numerical Values"
646+ )
620647
621- def apply_operation (
622- self , operation : Callable [[T ], U ]) -> AbstractList [U ]:
648+ def apply_operation (self , operation : Callable [[T ], U ]) -> AbstractList [U ]:
623649 """
624650 Applies a function on the list to create a new one.
625651 The values of the new list are created on the fly so any changes
0 commit comments