style(python): format with black

This commit is contained in:
GreasrySlug 2023-03-16 22:39:34 +09:00
parent 454224858b
commit 08ad656240
17 changed files with 208 additions and 36 deletions

View file

@ -2,8 +2,9 @@ from _erg_nat import Nat
from _erg_nat import NatMut
from _erg_result import Error
class Bool(Nat):
def try_new(b: bool): # -> Result[Nat]
def try_new(b: bool): # -> Result[Nat]
if b == True or b == False:
return Bool(b)
else:
@ -14,31 +15,40 @@ class Bool(Nat):
return "True"
else:
return "False"
def __repr__(self) -> str:
return self.__str__()
def mutate(self):
return BoolMut(self)
def invert(self):
return Bool(not self)
class BoolMut(NatMut):
value: Bool
def __init__(self, b: Bool):
self.value = b
def __repr__(self):
return self.value.__repr__()
def __hash__(self):
return self.value.__hash__()
def __eq__(self, other):
if isinstance(other, bool):
return self.value == other
else:
return self.value == other.value
def __ne__(self, other):
if isinstance(other, bool):
return self.value != other
else:
return self.value != other.value
def invert(self):
self.value = self.value.invert()