[PR jw/#7] auth.Auth: Add methods __eq__() and .__hash__()
All checks were successful
CI / Packaging - Kali Linux (push) Successful in 5m37s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 5m43s
CI / Packaging test (push) Successful in 0s

Merge pull request "auth.Auth: Add methods __eq__() and .__hash__()"

Upstream-repo: ssh://git@code.janware.com/janware/jw-python
Source-branch: jan/feature/20261125-auth-auth-add-methods-eq-and-hash
Target-branch: master
Reviewed-on: #7
This commit is contained in:
Jan Lindemann 2026-11-25 12:22:26 +01:00 • committed by janware Code
commit 1a183a505e
Signed by: Code Bot
GPG key ID: 66A5D2B295EE1224

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:
...