Skip to content

Commit 9b3b451

Browse files
nat-nGobot1234
andcommitted
Update src/betterproto/__init__.py
Co-authored-by: James <50501825+Gobot1234@users.noreply.github.com>
1 parent 8c821c2 commit 9b3b451

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/betterproto/__init__.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -529,26 +529,25 @@ def __post_init__(self) -> None:
529529
def __raw_get(self, name: str) -> Any:
530530
return super().__getattribute__(name)
531531

532-
def __eq__(self, other):
532+
def __eq__(self, other: T) -> bool:
533533
if type(self) is not type(other):
534534
return False
535535

536-
equal = True
537536
for field_name in self._betterproto.meta_by_field_name:
538537
self_val = self.__raw_get(field_name)
539538
other_val = other.__raw_get(field_name)
540539
if self_val is PLACEHOLDER and other_val is PLACEHOLDER:
541540
continue
542-
elif self_val is PLACEHOLDER:
541+
542+
if self_val is PLACEHOLDER:
543543
self_val = self._get_field_default(field_name)
544544
elif other_val is PLACEHOLDER:
545545
other_val = other._get_field_default(field_name)
546546

547547
if self_val != other_val:
548-
equal = False
549-
break
548+
return False
550549

551-
return equal
550+
return True
552551

553552
def __repr__(self) -> str:
554553
parts = []

0 commit comments

Comments
 (0)