Blacken the code.

This commit is contained in:
Simon Forman 2022-09-07 14:21:33 -07:00
parent 4f48ffbb5f
commit 88f3cc4bbe
1 changed files with 17 additions and 11 deletions

View File

@ -817,18 +817,18 @@ def BinaryLogicWrapper(f):
''' '''
Wrap functions that take two numbers and return a single result. Wrap functions that take two numbers and return a single result.
''' '''
@wraps(f) @wraps(f)
def inner(stack, expression, dictionary): def inner(stack, expression, dictionary):
try: try:
(a, (b, stack)) = stack (a, (b, stack)) = stack
except ValueError: except ValueError:
raise StackUnderflowError('Not enough values on stack.') raise StackUnderflowError('Not enough values on stack.')
if (not isinstance(a, bool) if not isinstance(a, bool) or not isinstance(b, bool):
or not isinstance(b, bool)
):
raise NotABoolError raise NotABoolError
result = f(b, a) result = f(b, a)
return (result, stack), expression, dictionary return (result, stack), expression, dictionary
return inner return inner
@ -836,20 +836,23 @@ def BinaryMathWrapper(func):
''' '''
Wrap functions that take two numbers and return a single result. Wrap functions that take two numbers and return a single result.
''' '''
@wraps(func) @wraps(func)
def inner(stack, expression, dictionary): def inner(stack, expression, dictionary):
try: try:
(a, (b, stack)) = stack (a, (b, stack)) = stack
except ValueError: except ValueError:
raise StackUnderflowError('Not enough values on stack.') raise StackUnderflowError('Not enough values on stack.')
if ( not isinstance(a, int) if (
not isinstance(a, int)
or not isinstance(b, int) or not isinstance(b, int)
or isinstance(a, bool) or isinstance(a, bool)
or isinstance(b, bool) or isinstance(b, bool)
): ):
raise NotAnIntError raise NotAnIntError
result = func(b, a) result = func(b, a)
return (result, stack), expression, dictionary return (result, stack), expression, dictionary
return inner return inner
@ -877,8 +880,7 @@ def UnaryMathWrapper(f):
@wraps(f) @wraps(f)
def inner(stack, expression, dictionary): def inner(stack, expression, dictionary):
(a, stack) = stack (a, stack) = stack
if (not isinstance(b, int) if not isinstance(b, int) or isinstance(a, bool):
or isinstance(a, bool)):
raise NotAnIntError raise NotAnIntError
result = f(a) result = f(a)
return (result, stack), expression, dictionary return (result, stack), expression, dictionary
@ -968,7 +970,9 @@ class Def(object):
tribar = '\u2261' # '≡' tribar = '\u2261' # '≡'
def __init__(self, name, body): 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.__name__ = name
self.body = tuple(iter_stack(body)) self.body = tuple(iter_stack(body))
@ -985,7 +989,9 @@ class Def(object):
for line in stream: for line in stream:
if class_.tribar not in line: if class_.tribar not in line:
continue continue
name, body = text_to_expression(line.replace(class_.tribar, '')) name, body = text_to_expression(
line.replace(class_.tribar, '')
)
if name not in dictionary: if name not in dictionary:
inscribe(class_(name, body), dictionary) inscribe(class_(name, body), dictionary)