DOC: Fixes PR01, PR02 for Series.cat and Series.dt #58912
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ref #58504
When trying to fix PR01 and PR02 for Series.cat in #58750, I found that the current docstring validation raises these errors as false negatives. These false negatives occur for functions that are indirectly accessed through the Series accessors. Instead of the actual functions, they call
f(self, *args, **kwargs)
in pandas/core/accessor.py. When validating the docstrings, f's signature is used instead of the actual function's signature. PR01 is raised since the docstring does not have *args and **kwargs in the signature, and PR02 is raised since the parameters in the docstrings are not in the signature. I found this happens for Series.cat and Series.dt.I added a check before validating the docstring to replace accessor names with the actual function's name. I'm sure there's a better way to implement this, but I'm not too knowledgeable on how these accessors work exactly. I couldn't figure out a way to get the delegated function from an accessor so I ended up with this crude solution using string literals.
Any suggestions or advice would be really helpful!