Improved list to handle typing

This commit is contained in:
2021-07-26 15:48:42 +02:00
parent b7be439381
commit 94949394de
4 changed files with 36 additions and 1 deletions

View File

@@ -10,3 +10,9 @@ class List(Iterable):
if values is not None:
self.extend(values)
def append(self, __object: object) -> None:
if self._type is not None and type(__object) != self._type and not isinstance(type(__object), self._type):
raise Exception(f'Unexpected type: {type(__object)}')
super().append(__object)