diff --git a/swh/model/model.py b/swh/model/model.py --- a/swh/model/model.py +++ b/swh/model/model.py @@ -289,8 +289,8 @@ object_type: Final = "person" fullname = attr.ib(type=bytes, validator=type_validator()) - name = attr.ib(type=Optional[bytes], validator=type_validator()) - email = attr.ib(type=Optional[bytes], validator=type_validator()) + name = attr.ib(type=Optional[bytes], validator=type_validator(), eq=False) + email = attr.ib(type=Optional[bytes], validator=type_validator(), eq=False) @classmethod def from_fullname(cls, fullname: bytes): diff --git a/swh/model/tests/test_model.py b/swh/model/tests/test_model.py --- a/swh/model/tests/test_model.py +++ b/swh/model/tests/test_model.py @@ -646,6 +646,18 @@ assert expected_person == Person.from_fullname(person) +def test_person_comparison(): + """Check only the fullname attribute is used to compare Person objects + + """ + person = Person(fullname=b"p1", name=None, email=None) + assert attr.evolve(person, name=b"toto") == person + assert attr.evolve(person, email=b"toto@example.com") == person + + person = Person(fullname=b"", name=b"toto", email=b"toto@example.com") + assert attr.evolve(person, fullname=b"dude") != person + + # Content