Whole file

meadsteve/lagom

The author described this change as Fix bug where typed self caused loading issues. It counts as a record because the check below fails on the code as it stood at 0bf84398d and passes on d50fabea6, with nothing else changed between the two runs.

Fix saved2020-06-13
Sharing licenceMIT · LICENSE
Change size+6 2

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

Fix bug where typed self caused loading issues

The change

206206
207207 def _reflection_build(self, dep_type: Type[X]) -> X:
208208 spec = self._reflector.get_function_spec(dep_type.__init__)
209- sub_deps = self._infer_dependencies(spec)
209+ sub_deps = self._infer_dependencies(spec, types_to_skip={dep_type})
210210 try:
211211 return dep_type(**sub_deps) # type: ignore
212212 except TypeError as type_error:
218218 suppress_error=False,
219219 keys_to_skip: List[str] = None,
220220 skip_pos_up_to=0,
221+ types_to_skip: Set[Type] = None,
221222 ):
222223 supplied_arguments = spec.args[0:skip_pos_up_to]
223224 keys_to_skip = (keys_to_skip or []) + supplied_arguments
225+ types_to_skip = types_to_skip or set()
224226 sub_deps = {
225227 key: self.resolve(sub_dep_type, suppress_error=suppress_error)
226228 for (key, sub_dep_type) in spec.annotations.items()
227- if sub_dep_type != Any and key not in keys_to_skip
229+ if sub_dep_type != Any
230+ and (key not in keys_to_skip)
231+ and (sub_dep_type not in types_to_skip)
228232 }
229233 filtered_deps = {key: dep for (key, dep) in sub_deps.items() if dep is not None}
230234 return filtered_deps

The check that tells the two apart

failpass·tests/test_objects.py::test_explicitly_typing_self_doesnt_cause_problems

Check file tests/test_objects.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 it0bf84398d8c34c2453326a5026b022be54ae807a
Broken version dated2020-06-13
Modulelagom.container
Units changedContainer
Fingerprintf57d380b477f7d41
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 meadsteve/lagom