From 95ecc1ac8caddbe618a389d0e15c52dcf0f2bdf5 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 29 Jan 2024 14:37:36 -0500 Subject: [PATCH 1/2] Update the test suite submodule. --- JSON-Schema-Test-Suite | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JSON-Schema-Test-Suite b/JSON-Schema-Test-Suite index 1bd999a..b41167c 160000 --- a/JSON-Schema-Test-Suite +++ b/JSON-Schema-Test-Suite @@ -1 +1 @@ -Subproject commit 1bd999ac16bd8d3fdb5c44ef13a0759aefb4ab73 +Subproject commit b41167c7468403eaaf88f2b05f835dce16c8403f From 2e7555d67ca5a35e912c7cdd1ebacfc93d0e2166 Mon Sep 17 00:00:00 2001 From: Julian Berman Date: Mon, 29 Jan 2024 14:55:50 -0500 Subject: [PATCH 2/2] Fix `not: {}` schemas when given falsy instances. These were improperly considering objects like None to be valid under that schema. The fix here simply adds {} as another special cased schema, since presumably the `is True` block is meant as an optimization. Note that there are of course many other things you can give to `not` which disallow any possible instance, like `not: {"title": "foo"}` but the fallback block should presumably catch them. The block that was deleted here never looks correct to me (so I've simply deleted it). Running the updated test suite would seem to confirm, as this change takes the suite from: 321 failed, 3268 passed, 12 deselected, 152 xfailed, 140 xpassed to 309 failed, 3280 passed, 12 deselected, 152 xfailed, 140 xpassed i.e. a strict increase in compliance. --- fastjsonschema/draft04.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fastjsonschema/draft04.py b/fastjsonschema/draft04.py index e2d9c8a..43a08d5 100644 --- a/fastjsonschema/draft04.py +++ b/fastjsonschema/draft04.py @@ -206,13 +206,10 @@ def generate_not(self): means everything is invalid. """ not_definition = self._definition['not'] - if not_definition is True: + if not_definition is True or not_definition == {}: self.exc('{name} must not be there', rule='not') elif not_definition is False: return - elif not not_definition: - with self.l('if {}:', self._variable): - self.exc('{name} must NOT match a disallowed definition', rule='not') else: with self.l('try:', optimize=False): self.generate_func_code_block(not_definition, self._variable, self._variable_name)