Skip to content

__lt__ operator doesn't work with two Literals #213

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions