Skip to content

InvalidNumber.__eq__ method doesn't handle dict comparison correctly #37

@lysykot

Description

@lysykot

The "eq" method in the InvalidNumber class has a bug when comparing with dictionaries. Currently, it assumes "other" is always an InvalidNumber object and tries to access "other.dict", which fails when other is already a dictionary.

Current Implementation:
def __eq__(self, other): return other and self.__dict__ == other.__dict__

Expected Behavior:
The "eq" method should handle both InvalidNumber objects and dictionaries:
def __eq__(self, other): if other is None: return False if isinstance(other, dict): return self.__dict__ == other if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False

Branch:
Master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions