Whole file

keleshev/schema

The author described this change as add strict flag in Schema class to skip wrong key validation without wildcard. It counts as a record because the check below fails on the code as it stood at 695b79367 and passes on db5ba6c15, with nothing else changed between the two runs.

Fix saved2016-02-16
Sharing licenceMIT · LICENSE-MIT
Change size+3 2

What the code was meant to do, written into the code itself as a save note

add strict flag in Schema class to skip wrong key validation without wildcard

The change

9696
9797 class Schema(object):
9898
99- def __init__(self, schema, error=None):
99+ def __init__(self, schema, error=None, strict=True):
100100 self._schema = schema
101101 self._error = error
102+ self._strict = strict
102103
103104 def __repr__(self):
104105 return '%s(%r)' % (self.__class__.__name__, self._schema)
141142 missing_keys = required - coverage
142143 s_missing_keys = ", ".join(repr(k) for k in missing_keys)
143144 raise SchemaError('Missing keys: ' + s_missing_keys, e)
144- if len(new) != len(data):
145+ if self._strict and (len(new) != len(data)):
145146 wrong_keys = set(data.keys()) - set(new.keys())
146147 s_wrong_keys = ', '.join(repr(k) for k in sorted(wrong_keys,
147148 key=repr))

The check that tells the two apart

failpass·test_schema.py::test_no_strict_schema

Check file test_schema.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 it695b793675eb66c99e0dac91cdbbc27dde27c491
Broken version dated2016-02-16
Moduleschema
Units changedSchema
Fingerprint555b3ef2700abb2e
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 keleshev/schema