Closed shinnar closed 6 months ago
Similar to #1222 NaN
doesn't exist in JSON, and therefore not in JSON Schema so it isn't really supported by this library and there's certainly no guarantees about how it behaves. That being said, I'm happy nonetheless to merge your PR, but only really because an is
check might help in a tiny way for other comparison speedups. There again would be no promises about behavior of nan
in particular.
As a result of the change in a9bf13ca04044e8b7320dc76a49c4dd287951686
equal
(which uses ==) is now used for all enum (https://github.com/python-jsonschema/jsonschema/blob/main/jsonschema/_keywords.py#L269) validations.As a result, if an enum has a
nan
in it, it will no longer validate anan
instance, sincenan == nan
returns False. The previous behaviour usedin
, which calls the containers__contains__
method. For standard containers, that uses bothis
and==
to check for comparison, which is why this worked before this commit.One possible fix would be to check if
one is two
at the beginning of theequal
method.