Skip to content

Commit

Permalink
fix py38 warning about 'is'
Browse files Browse the repository at this point in the history
  • Loading branch information
2kjiejie authored and jamesls committed Jan 20, 2022
1 parent 4b7802d commit 489e903
Showing 1 changed file with 1 addition and 25 deletions.
26 changes: 1 addition & 25 deletions jmespath/visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,11 @@


def _equals(x, y):
if _is_special_integer_case(x, y):
if type(x) != type(y):
return False
else:
return x == y


def _is_special_integer_case(x, y):
# We need to special case comparing 0 or 1 to
# True/False. While normally comparing any
# integer other than 0/1 to True/False will always
# return False. However 0/1 have this:
# >>> 0 == True
# False
# >>> 0 == False
# True
# >>> 1 == True
# True
# >>> 1 == False
# False
#
# Also need to consider that:
# >>> 0 in [True, False]
# True
if type(x) is int and (x == 0 or x == 1):
return y is True or y is False
elif type(y) is int and (y == 0 or y == 1):
return x is True or x is False


def _is_comparable(x):
# The spec doesn't officially support string types yet,
# but enough people are relying on this behavior that
Expand Down

0 comments on commit 489e903

Please sign in to comment.