Skip to content

The use of @cache_readonly removes the docstring of attributes #18197

Closed
@jorisvandenbossche

Description

@jorisvandenbossche

Related to our general investigations into the api docs (#18147), there is the problem that those attributes that are decorated with @cache_readonly no longer have a docstring. Eg:

In [1]: pd.Index.is_unique?
Type:        NoneType
String form: None
Docstring:   <no docstring>

If I simply comment out the cache_readonly for this attribute (just as a check this is the culprit), I get:

In [1]: pd.Index.is_unique?
Signature: pd.Index.is_unique(self)
Docstring: return if the index has unique values 
File:      ~/scipy/pandas/pandas/core/indexes/base.py
Type:      function

(although it seems to think it is a function, although inspect.isfunction correctly gives false)

Just posting this here as a reminder to further investigate, and to see if somebody directly has an idea how to fix this (@jreback ?). The main problem is that this decorator is implemented in cython, and we probably can't use something like functools.wraps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions