(func: typing.Callable)
| 106 | |
| 107 | |
| 108 | def cached_property(func: typing.Callable) -> property: |
| 109 | cached_name = f"_cached_{func}" |
| 110 | sentinel = object() |
| 111 | |
| 112 | def inner(instance: object): |
| 113 | cache = getattr(instance, cached_name, sentinel) |
| 114 | if cache is not sentinel: |
| 115 | return cache |
| 116 | result = func(instance) |
| 117 | setattr(instance, cached_name, result) |
| 118 | return result |
| 119 | |
| 120 | return property(inner) |
| 121 | |
| 122 | |
| 123 | # Python 3.10 changed representation of enums. We use well-defined object |
nothing calls this directly
no outgoing calls
no test coverage detected