Whole file
horejsek/python-fastjsonschema
The author described this change as “Fix of uniqueItems when used with other than array type”. It counts as a record because the check below fails on the code as it stood at 4c8e5fc37 and passes on 3252d066a, with nothing else changed between the two runs.
Fix saved2019-09-26
Sharing licenceBSD-3-Clause · LICENSE
Change size+5 −3
What the code was meant to do, written into the code itself as a save note
Fix of uniqueItems when used with other than array type
The change
| 337 | 337 | >>> timeit.timeit("np.unique(x).size == len(x)", "x=range(100)+range(100); import numpy as np", number=100000) | |
| 338 | 338 | 2.1439831256866455 | |
| 339 | 339 | """ | |
| 340 | - | self.create_variable_with_length() | |
| 341 | - | with self.l('if {variable}_len > len(set(str({variable}_x) for {variable}_x in {variable})):'): | |
| 342 | - | self.l('raise JsonSchemaException("{name} must contain unique items")') | |
| 340 | + | self.create_variable_is_list() | |
| 341 | + | with self.l('if {variable}_is_list:'): | |
| 342 | + | self.create_variable_with_length() | |
| 343 | + | with self.l('if {variable}_len > len(set(str({variable}_x) for {variable}_x in {variable})):'): | |
| 344 | + | self.l('raise JsonSchemaException("{name} must contain unique items")') | |
| 343 | 345 | ||
| 344 | 346 | def generate_items(self): | |
| 345 | 347 | """ |
The check that tells the two apart
fail→pass·tests/test_array.py::test_min_and_unique_items
Check file tests/test_array.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it4c8e5fc37f576fd66e78be6e34c83a3dc8ef0b99
Broken version dated2019-09-25
Modulefastjsonschema.draft04
Units changedCodeGeneratorDraft04
Fingerprint47447faeb8d9fd4e
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in horejsek/python-fastjsonschema
- 2026-07-20fix: don't leak variables from not blocks into the outer scope
- 2022-07-17Fix false unique items
- 2020-08-17Fix missing dependenices