File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -295,6 +295,15 @@ class Example:
295295 just paste the example above into a Python interpreter). In that case,
296296 an empty dictionary is returned.
297297
298+ The same limitation means dynamically defined classes will result in
299+ an empty dictionary.
300+
301+ .. note::
302+
303+ This function uses a cache, so subsequent calls on the same class will
304+ return a cached value. As dynamic classes are not supported, this is
305+ not expected to be a problem.
306+
298307 :param cls: The class to inspect
299308 :return: A mapping of attribute names to docstrings. Note that this will be
300309 wrapped in a `types.MappingProxyType` to prevent accidental modification.
Original file line number Diff line number Diff line change @@ -45,6 +45,10 @@ def test_docstrings_are_cached():
4545 """Check that the docstrings aren't being regenerated every time."""
4646 docs1 = get_class_attribute_docstrings (Example )
4747 docs2 = get_class_attribute_docstrings (Example )
48+ # The dictionary of attribute docstrings is cached, keyed on the
49+ # class. The test below checks the same object is returned, not
50+ # just one with the same values in it - this implies the cache
51+ # is working.
4852 assert docs1 is docs2
4953
5054
You can’t perform that action at this time.
0 commit comments