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

5858 ('minProperties', self.generate_min_properties),
5959 ('maxProperties', self.generate_max_properties),
6060 ('required', self.generate_required),
61+ # Check dependencies before properties generates default values.
62+ ('dependencies', self.generate_dependencies),
6163 ('properties', self.generate_properties),
6264 ('patternProperties', self.generate_pattern_properties),
6365 ('additionalProperties', self.generate_additional_properties),
64- ('dependencies', self.generate_dependencies),
6566 ))
6667
6768 @property
559560 """
560561 self.create_variable_is_dict()
561562 with self.l('if {variable}_is_dict:'):
562- self.create_variable_keys()
563+ isEmpty = True
563564 for key, values in self._definition["dependencies"].items():
564565 if values == [] or values is True:
565566 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)):
567569 if values is False:
568570 self.exc('{} in {name} must not be there', key, rule='dependencies')
569571 elif isinstance(values, list):
570572 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)):
572574 self.exc('{name} missing dependency {} for {}', self.e(value), self.e(key), rule='dependencies')
573575 else:
574576 self.generate_func_code_block(values, self._variable, self._variable_name, clear_variables=True)
577+ if isEmpty:
578+ self.l('pass')
575579

The check that tells the two apart

failpass·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.

Other bugs found in horejsek/python-fastjsonschema