From 88f3cc4bbee3240a1a923a505e7092a121ffa2f8 Mon Sep 17 00:00:00 2001 From: Simon Forman Date: Wed, 7 Sep 2022 14:21:33 -0700 Subject: [PATCH] Blacken the code. --- implementations/Python/simplejoy.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/implementations/Python/simplejoy.py b/implementations/Python/simplejoy.py index c29996c..c466c80 100755 --- a/implementations/Python/simplejoy.py +++ b/implementations/Python/simplejoy.py @@ -817,18 +817,18 @@ def BinaryLogicWrapper(f): ''' Wrap functions that take two numbers and return a single result. ''' + @wraps(f) def inner(stack, expression, dictionary): try: (a, (b, stack)) = stack except ValueError: raise StackUnderflowError('Not enough values on stack.') - if (not isinstance(a, bool) - or not isinstance(b, bool) - ): + if not isinstance(a, bool) or not isinstance(b, bool): raise NotABoolError result = f(b, a) return (result, stack), expression, dictionary + return inner @@ -836,20 +836,23 @@ def BinaryMathWrapper(func): ''' Wrap functions that take two numbers and return a single result. ''' + @wraps(func) def inner(stack, expression, dictionary): try: (a, (b, stack)) = stack except ValueError: raise StackUnderflowError('Not enough values on stack.') - if ( not isinstance(a, int) + if ( + not isinstance(a, int) or not isinstance(b, int) - or isinstance(a, bool) - or isinstance(b, bool) - ): + or isinstance(a, bool) + or isinstance(b, bool) + ): raise NotAnIntError result = func(b, a) return (result, stack), expression, dictionary + return inner @@ -877,8 +880,7 @@ def UnaryMathWrapper(f): @wraps(f) def inner(stack, expression, dictionary): (a, stack) = stack - if (not isinstance(b, int) - or isinstance(a, bool)): + if not isinstance(b, int) or isinstance(a, bool): raise NotAnIntError result = f(a) return (result, stack), expression, dictionary @@ -968,7 +970,9 @@ class Def(object): tribar = '\u2261' # '≡' def __init__(self, name, body): - self.__doc__ = f'{name} {self.tribar} {expression_to_string(body)}' + self.__doc__ = ( + f'{name} {self.tribar} {expression_to_string(body)}' + ) self.__name__ = name self.body = tuple(iter_stack(body)) @@ -985,7 +989,9 @@ class Def(object): for line in stream: if class_.tribar not in line: continue - name, body = text_to_expression(line.replace(class_.tribar, '')) + name, body = text_to_expression( + line.replace(class_.tribar, '') + ) if name not in dictionary: inscribe(class_(name, body), dictionary)