Unverified Commit f9792872 authored by Jakob Görgen's avatar Jakob Görgen
Browse files

fixed remaining patterns unreachable

parent 0a32b755
...@@ -30,18 +30,18 @@ class IdObj(abc.ABC): ...@@ -30,18 +30,18 @@ class IdObj(abc.ABC):
def __init__(self): def __init__(self):
self._id = next(self.__id_iter) self._id = next(self.__id_iter)
def check_type(obj, expected_type) -> bool: def check_type(obj, expected_type) -> bool:
""" """
Checks if obj has type or is a subtype of expected_type Checks if obj has type or is a subtype of expected_type
obj: an class object obj: an class object
expected_type: a type object expected_type: a type object
""" """
match obj: return isinstance(obj, expected_type)
case expected_type:
return True
case _:
return False
def has_expected_type(obj, expected_type) -> None: def has_expected_type(obj, expected_type) -> None:
if not check_type(obj=obj, expected_type=expected_type): if not check_type(obj=obj, expected_type=expected_type):
raise Exception(f"obj of type {type(obj)} has not the type or is not a subtype of {type(expected_type)}") raise Exception(
\ No newline at end of file f"obj of type {type(obj)} has not the type or is not a subtype of {type(expected_type)}"
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment