Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

validating nan in an enum is no longer supported #1223

Closed
shinnar opened this issue Feb 16, 2024 · 1 comment
Closed

validating nan in an enum is no longer supported #1223

shinnar opened this issue Feb 16, 2024 · 1 comment
Labels
Invalid Not a bug, PEBKAC, or an unsupported setup

Comments

@shinnar
Copy link
Contributor

shinnar commented Feb 16, 2024

As a result of the change in a9bf13c

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 a nan instance, since nan == nan returns False.
The previous behaviour used in, which calls the containers __contains__ method. For standard containers, that uses both is 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 the equal method.

@Julian
Copy link
Member

Julian commented Feb 16, 2024

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.

@Julian Julian closed this as completed Feb 16, 2024
@Julian Julian added the Invalid Not a bug, PEBKAC, or an unsupported setup label Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Invalid Not a bug, PEBKAC, or an unsupported setup
Projects
None yet
Development

No branches or pull requests

2 participants