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

Python NaN validates against all numeric limits, and shouldn't #1222

Closed
slbayer opened this issue Feb 14, 2024 · 2 comments
Closed

Python NaN validates against all numeric limits, and shouldn't #1222

slbayer opened this issue Feb 14, 2024 · 2 comments
Labels
Invalid Not a bug, PEBKAC, or an unsupported setup

Comments

@slbayer
Copy link

slbayer commented Feb 14, 2024

In the most recent version of python-jsonschema (4.21.1) using Python 3.10.11 on macOS 13.6.4:

>>> import jsonschema
>>> jsonschema.validate(float("nan"), {"type": "number", "minimum": 0})
>>> float("nan") >= 0
False
>>> jsonschema.validate(float("nan"), {"type": "number", "exclusiveMinimum": 0})
>>> float("nan") > 0
False

And so on. NaN is certainly a number, but it is not greater than 0, or greater than or equal to 0, etc.

@Julian
Copy link
Member

Julian commented Feb 14, 2024

NaN isn't part of the JSON data model, and therefore not part of the JSON Schema specification, so any results you get from it are somewhat bound to be nonsensical.

@Julian
Copy link
Member

Julian commented Feb 14, 2024

(For what it's worth, to elaborate on your specific example in the context of Python behavior, while nan isn't greater than 0, it's not less than it either, as float("nan") < 0 is also false.)

@Julian Julian closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2024
@Julian Julian added the Invalid Not a bug, PEBKAC, or an unsupported setup label Feb 16, 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