-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
Description
Since pandas has objects with the same API, e.g. DataFrame.fillna Series.fillna, some of these methods may leverage a shared docstring system using @Appender, @Substitution, @doc and variables named like shared_docsto dynamically generate docstring based on a template. While this helps reduce some duplication, the downsides are:
- The shared docstring system, at minimum, adds indirection and, at worse, is less clear than a hardcoded docstring for new contributions
- Since these docstrings are dynamic, they avoid docstring standardization and rules provide by Ruff. (These docstrings are validated by flake8 run in a subprocess, but it would be nice to remove this )
pandas/scripts/validate_docstrings.py
Line 203 in 98c9c7f
"flake8",
The task then is to replace methods that use @Appender, @Substitution or @doc with a hardcoded docstring after the function signature. Since there are many methods that use these decorators, this issue should be completed in multiple PRs ,and therefore, this issue can be worked on by multiple contributors.
For those interested in working on this issue:
- Comment below on which directory you'll be working on, e.g.
fillna - Submit a PR removing the above decorators from the method and inline and docstring substitutions made.
- If a shared docstring is defined on a class inherited by others, e.g.
NDFrame.fillnahas the docstring forSeries.fillnaandDataFrame.fillna, you may need to add language that clarifies application to both e.g.SeriesandDataFrame - If a docstring is not inherited by another object, you can print the
__doc__of a method in a Python terminal and copy-paste that as the new docstring.
- If a shared docstring is defined on a class inherited by others, e.g.
Once all uses of @Appender, @Substitution or @doc are removed, a separate PR to remove these objects would be welcome.