Whole file

bwindsor/typed-config

The author described this change as Add test for using same child config twice, and fix bug where one instance is created instead of two. It counts as a record because the check below fails on the code as it stood at 51f67f163 and passes on 0141681d8, with nothing else changed between the two runs.

Fix saved2021-09-09
Sharing licenceMIT · LICENSE
Change size+4 2

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

Add test for using same child config twice, and fix bug where one instance is created instead of two

The change

112112
113113 @property
114114 def wrapped_f(self):
115- function_name = cls.__name__
116- attr_name = '_' + function_name
115+ attr_name = '_' + self._get_property_name_from_object(wrapped_f)
117116 if not hasattr(self, attr_name):
118117 setattr(self, attr_name, typing.cast(Type[Config], cls)(provider=self._provider))
119118 return getattr(self, attr_name)
200199 if key_key_name is not None:
201200 return key_key_name
202201
202+ return self._get_property_name_from_object(property_object)
203+
204+ def _get_property_name_from_object(self, property_object: property) -> str:
203205 members = inspect.getmembers(self.__class__, lambda x: x is property_object)
204206 assert len(members) == 1
205207 return members[0][0].upper()

The check that tells the two apart

failpass·test/test_configuration.py::test_reuse_child_config

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 it51f67f16326cb8172b812e21d1f13e23722faf11
Broken version dated2021-09-09
Moduletypedconfig.config
Units changedConfig, group_key
Fingerprint9f288d5fa9f13e46
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 bwindsor/typed-config