__eq__ operators

This commit is contained in:
Johan B.W. de Vries 2023-04-11 09:49:07 +02:00
parent bb9ac649bf
commit 8c5a2893d6
2 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,4 @@
from typing import List from typing import Any, List
from .valuetype import ValueType from .valuetype import ValueType
@ -14,6 +14,12 @@ class MethodArgument:
self.name = name self.name = name
self.value_type = value_type self.value_type = value_type
def __eq__(self, other: Any) -> bool:
if not isinstance(other, MethodArgument):
raise NotImplementedError
return self.name == other.name and self.value_type == other.value_type
class Method: class Method:
__slots__ = ('name', 'args', 'return_type', ) __slots__ = ('name', 'args', 'return_type', )

View File

@ -1,3 +1,6 @@
from typing import Any
class ValueType: class ValueType:
__slots__ = ('name', ) __slots__ = ('name', )
@ -6,6 +9,12 @@ class ValueType:
def __init__(self, name: str) -> None: def __init__(self, name: str) -> None:
self.name = name self.name = name
def __eq__(self, other: Any) -> bool:
if not isinstance(other, ValueType):
raise NotImplementedError
return self is other
bytes = ValueType('bytes') bytes = ValueType('bytes')