Add a smarter version of Django's @cached_property decorator.
Review Request #8488 — Created Oct. 25, 2016 and submitted
Django's
@cached_propertydecorator is very useful for implementing
properties that call expensive methods, as it takes care of all the
caching. Unfortunately, it doesn't behave like a standard property. It
overwrites the documentation and does not retain the name and
attributes. Introspecting the property (such as for documentation
generation purposes) results in some bad information.This introduces a smarter version of
@cached_property. It's a drop-in
replacement that retains the documentation and attributes, like a normal
decorator would.Unit tests were added to ensure it works correctly, and existing call
sites were updated to use it.
Unit tests pass.
Built some docs and saw that the doc string from the method wrapped by
@cached_propertywas showing up instead of the one on
@cached_propertyitself.
| Description | From | Last Updated |
|---|---|---|
|
Docstring? |
|
- Change Summary:
-
Added a missing test docstring.
- Commit:
-
274b98488a47e003486e95d45f9917c9f5b1f70ef08abb8d96836bbe7b62a5c73ebcd289c9d38e89
Tool: Pyflakes Processed Files: djblets/util/tests.py djblets/datagrid/grids.py djblets/util/decorators.py Tool: PEP8 Style Checker Processed Files: djblets/util/tests.py djblets/datagrid/grids.py djblets/util/decorators.py