One function
key in bwindsor/typed-config
The author described this change as “Fix: don't cast default value”. It counts as a record because the check below fails on the code as it stood at 9af71de5a and passes on d085f6c22, with nothing else changed between the two runs.
Projectbwindsor/typed-config
Fix saved2020-04-10
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a docstring
Provides a getter for a configuration key Parameters ---------- section_name: section name where the key resides. If not specified, the @section decorator should be used on the Config class to specify it key_name: key name within the specified section. If not specified, the python key name will be capitalised and used required: optional, default True. Whether the key is required or optional cast: optional, default None (no cast). Function taking a string argument and returning the parsed value default: optional, default None. If required is set to False, the value to use if the config value is not found
The change
| 67 | 67 | value = default | |
| 68 | 68 | ||
| 69 | 69 | # If a casting function has been specified then cast to the required data type | |
| 70 | - | if cast is not None: | |
| 70 | + | if value is not None and cast is not None: | |
| 71 | 71 | value = cast(value) | |
| 72 | 72 | ||
| 73 | 73 | # Cache this for next time if still not none |
The check that tells the two apart
fail→pass·test/test_configuration.py::test_cast_with_default
Check file test/test_configuration.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 it9af71de5ab7426a9711965aa83759d0b22e42454
Broken version dated2020-03-11
Moduletypedconfig.config
Units changedkey
Fingerprintd4b078e996c9a625
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.