-
-
Notifications
You must be signed in to change notification settings - Fork 595
Closed
Labels
BugSomething doesn't work the way it should.Something doesn't work the way it should.
Description
I'm working on some schema canonicalisation and intersection logic for hypothesis-jsonschema
, and encountered the surprising-to-me property that jsonschema
sometimes considers 0 == False
(and similarly 1 == True
):
# All of these pass:
validate(0, {"just": False}) # 0 == False
validate(False, {"enum": [0.0]}) # 0.0 == False
# Fails, "On instance: [0, 0]", despite `unbool` logic
validate([0, False], {"uniqueItems": True})
According to the core spec, instances are only equal if they are of the same type.
(and there is only one number type in JSON, so 1 == 1.0
)
The validation spec doesn't actually say anything about how value equality (ctrl-f "equal") should be defined, but I certainly found this surprising and the uniqueItems
message convinced me to report it.
Metadata
Metadata
Assignees
Labels
BugSomething doesn't work the way it should.Something doesn't work the way it should.