auth.Auth: Add methods __eq__() and .__hash__() #7

Merged
Jan Lindemann merged 1 commit from jan/feature/20261125-auth-auth-add-methods-eq-and-hash into master 2026-11-25 12:22:27 +01:00 AGit

View file

@ -3,7 +3,7 @@ from __future__ import annotations
import abc
from enum import Enum, Flag, auto
from typing import TYPE_CHECKING, Any, Self, Sequence, TypeAlias, cast
from typing import TYPE_CHECKING, Any, Self, Sequence, TypeAlias, cast, override
from ..Config import Config
from ..enum_helper import kebab_to_pascal
@ -32,6 +32,16 @@ class Kind(Flag):
class Entity(abc.ABC): # export
@override
def __eq__(self, other: Any) -> bool:
if not isinstance(other, Entity):
return NotImplemented
return (self.kind, self.name) == (other.kind, other.name)
@override
def __hash__(self) -> int:
return hash((self.kind, self.name))
@abc.abstractmethod
def _kind(self) -> Kind:
...