* 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
def data(self, value):
self.__data = value
def __eq__(self, other):
if hasattr(other, "data"):
return self.data == other.data
return self.data == other
def __ne__(self, other):
return not self == other
@ -71,7 +71,7 @@ class StackObj:
def next(self, value):
if isinstance(value, (self.__class__, None.__class__)):
self.__next = value
@classmethod
def wrap(cls, value):
return value if isinstance(value, cls) else cls(value)
@ -87,7 +87,7 @@ class Stack:
def __init__(self, data=None):
self.top = None
self.load(data or [])
def __iter__(self):
obj = self.top
while obj:
@ -106,12 +106,12 @@ class Stack:
self.top = obj
else:
self.bottom.next = obj
def push_front(self, value):
obj = StackObj.wrap(value)
obj.next = self.top
self.top = obj
def pop(self) -> StackObj:
if not self.top:
return None
@ -123,14 +123,14 @@ class Stack:
if b == self.top:
self.top = None
return b
def load(self, data):
for x in data:
self.push_back(x)
def __len__(self):
return sum(1 for _ in self)
def validate_index(self, idx: int):
if not isinstance(idx, int) or not 0 <= idx < len(self):
raise IndexError("неверный индекс")
@ -143,18 +143,18 @@ class Stack:
def __setitem__(self, idx: int, value):
self.validate_index(idx)
if idx == len(self):
self.push(value)
return
prev = self.top
for i, v in enumerate(self):
prev = v
if idx == i:
old = v
break
value = StackObj.wrap(value)
value.next = old.next
if idx > 0:
@ -167,29 +167,29 @@ class Stack:
def __str__(self):
return " -> ".join(map(str, self.get_data()))
def __repr__(self):
return f"{self.__class__.__name__}({self.get_data()!r})"
def tests():
code = (
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'(7n-%(6u1Yx6r-Nu+fLmwa~rLxY3Uw(6rF7(7n*T(Tm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