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.
Projectkeleshev/schema
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
| 96 | 96 | ||
| 97 | 97 | class Schema(object): | |
| 98 | 98 | ||
| 99 | - | def __init__(self, schema, error=None): | |
| 99 | + | def __init__(self, schema, error=None, strict=True): | |
| 100 | 100 | self._schema = schema | |
| 101 | 101 | self._error = error | |
| 102 | + | self._strict = strict | |
| 102 | 103 | ||
| 103 | 104 | def __repr__(self): | |
| 104 | 105 | return '%s(%r)' % (self.__class__.__name__, self._schema) | |
| ⋯ | |||
| 141 | 142 | missing_keys = required - coverage | |
| 142 | 143 | s_missing_keys = ", ".join(repr(k) for k in missing_keys) | |
| 143 | 144 | raise SchemaError('Missing keys: ' + s_missing_keys, e) | |
| 144 | - | if len(new) != len(data): | |
| 145 | + | if self._strict and (len(new) != len(data)): | |
| 145 | 146 | wrong_keys = set(data.keys()) - set(new.keys()) | |
| 146 | 147 | s_wrong_keys = ', '.join(repr(k) for k in sorted(wrong_keys, | |
| 147 | 148 | key=repr)) | |
The check that tells the two apart
fail→pass·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
- 2026-06-15Fix custom error on a key schema being lost for wrong keys
- 2026-06-13Fix TypeError when building the key error message for a tuple key
- 2025-02-27fix: JSON Schema missing title in subschemas
- 2017-01-17fix: Schema can be inherited (#127)
- 2015-09-26Fix reliance on `__name__` of callables
- 2014-02-03Handle wrong keys better. Fixes #3 and #15