Whole file
horejsek/python-fastjsonschema
The author described this change as “Fix missing dependenices”. It counts as a record because the check below fails on the code as it stood at 8c8a05c76 and passes on 400b11f8e, with nothing else changed between the two runs.
Fix saved2020-08-17
Sharing licenceBSD-3-Clause · LICENSE
Change size+8 −4
What the code was meant to do, written into the code itself as a save note
Fix missing dependenices
The change
| 58 | 58 | ('minProperties', self.generate_min_properties), | |
| 59 | 59 | ('maxProperties', self.generate_max_properties), | |
| 60 | 60 | ('required', self.generate_required), | |
| 61 | + | # Check dependencies before properties generates default values. | |
| 62 | + | ('dependencies', self.generate_dependencies), | |
| 61 | 63 | ('properties', self.generate_properties), | |
| 62 | 64 | ('patternProperties', self.generate_pattern_properties), | |
| 63 | 65 | ('additionalProperties', self.generate_additional_properties), | |
| 64 | - | ('dependencies', self.generate_dependencies), | |
| 65 | 66 | )) | |
| 66 | 67 | ||
| 67 | 68 | @property | |
| ⋯ | |||
| 559 | 560 | """ | |
| 560 | 561 | self.create_variable_is_dict() | |
| 561 | 562 | with self.l('if {variable}_is_dict:'): | |
| 562 | - | self.create_variable_keys() | |
| 563 | + | isEmpty = True | |
| 563 | 564 | for key, values in self._definition["dependencies"].items(): | |
| 564 | 565 | if values == [] or values is True: | |
| 565 | 566 | continue | |
| 566 | - | with self.l('if "{}" in {variable}_keys:', self.e(key)): | |
| 567 | + | isEmpty = False | |
| 568 | + | with self.l('if "{}" in {variable}:', self.e(key)): | |
| 567 | 569 | if values is False: | |
| 568 | 570 | self.exc('{} in {name} must not be there', key, rule='dependencies') | |
| 569 | 571 | elif isinstance(values, list): | |
| 570 | 572 | for value in values: | |
| 571 | - | with self.l('if "{}" not in {variable}_keys:', self.e(value)): | |
| 573 | + | with self.l('if "{}" not in {variable}:', self.e(value)): | |
| 572 | 574 | self.exc('{name} missing dependency {} for {}', self.e(value), self.e(key), rule='dependencies') | |
| 573 | 575 | else: | |
| 574 | 576 | self.generate_func_code_block(values, self._variable, self._variable_name, clear_variables=True) | |
| 577 | + | if isEmpty: | |
| 578 | + | self.l('pass') | |
| 575 | 579 | ||
The check that tells the two apart
fail→pass·tests/test_object.py::test_dependencies[value1-expected1]
Check file tests/test_object.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 it8c8a05c76bd6a8a346dcd9185d95baab110a04c5
Broken version dated2020-03-19
Modulefastjsonschema.draft04
Units changedCodeGeneratorDraft04
Fingerprintf119b88442df0fc1
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.