Link.__eq__: return NotImplemented instead of raising NotImplementedError (#7611)

This commit is contained in:
Adrian 2026-06-12 14:56:15 +02:00 committed by GitHub
parent b08ed1cf05
commit 983e6c1182
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 1 deletions

View File

@ -39,7 +39,7 @@ class Link:
def __eq__(self, other: object) -> bool:
if not isinstance(other, Link):
raise NotImplementedError
return NotImplemented
return (
self.url == other.url
and self.text == other.text

View File

@ -55,3 +55,7 @@ class TestLink:
def test_bytes_url(self):
with pytest.raises(TypeError):
Link(b"http://www.example.com/\xc2\xa3")
def test_eq_non_link(self):
url = "http://example.com"
assert Link(url) != url