Skip to content

__lt__ operator doesn't work with two Literals #213

@bitplane

Description

@bitplane

Describe the bug
As per title, object.some_number < object.some_other_number raises TypeError

Example Schema and code

{
  "title":"whatever",
  "test": {"type": "number"}
}

>>> whatever.test < whatever.test
>>> whatever.test <= whatever.test
>>> whatever.test >= whatever.test

Expected behaviour
Returns a boolean value

Actual behaviour
Raises TypeError because int.__lt__ doesn't know how to deal with a Literal.

Suggested fix

In Literal.__lt__(self, other), use an isinstance(Literal, other) check, compare with other._value if it's another Literal

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions