One function
CachingReflector in meadsteve/lagom
The author described this change as “fix bug that meant forward refs weren't handled correctly”. It counts as a record because the check below fails on the code as it stood at 5edd1e1f2 and passes on 05a73109b, with nothing else changed between the two runs.
Projectmeadsteve/lagom
Fix saved2020-06-13
Sharing licenceMIT · LICENSE
Change size+3 −4
What the code was meant to do, written into the code itself as a docstring
Takes a function and returns an object representing the function's type signature. Results are cached so subsequent calls do not need to call the reflection API.
The change
| 23 | 23 | """ | |
| 24 | 24 | if func not in self._reflection_cache: | |
| 25 | 25 | spec = inspect.getfullargspec(func) | |
| 26 | - | ret = spec.annotations.pop(RETURN_ANNOTATION, None) | |
| 27 | - | self._reflection_cache[func] = FunctionSpec( | |
| 28 | - | spec.args, spec.annotations, ret | |
| 29 | - | ) | |
| 26 | + | annotations = get_type_hints(func) | |
| 27 | + | ret = annotations.pop(RETURN_ANNOTATION, None) | |
| 28 | + | self._reflection_cache[func] = FunctionSpec(spec.args, annotations, ret) | |
| 30 | 29 | return self._reflection_cache[func] |
The check that tells the two apart
fail→pass·tests/test_objects.py::test_forward_refs_are_fine
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 it5edd1e1f254bf68a4a0ce149a0fbffa964087906
Broken version dated2020-06-13
Modulelagom.util.reflection
Units changedCachingReflector
Fingerprintb7a01779352c22ea
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.