forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-34868: [Python] Share docstrings between classes (apache#34894)
### Rationale for this change Python classes sometimes duplicate docstrings, but change one word such as class name. Add a decorator function as a utility to help deduplicate docstring descriptions. Only works in Python. Does not work in Cython due to this CPython issue python/cpython#91309. ### What changes are included in this PR? Add a decorator `@ doc` that can copy, concatenate, and/or format docstrings between classes. ### Are these changes tested? Tests added. ``` >>> import pyarrow >>> from pyarrow.filesystem import FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper >>> from pyarrow.hdfs import HadoopFileSystem >>> for fs in [FileSystem, LocalFileSystem, DaskFileSystem, S3FSWrapper, HadoopFileSystem]: ... print(fs.__name__) ... print(fs.isdir.__doc__) ... FileSystem Return True if path is a directory. Parameters ---------- path : str Path to check. LocalFileSystem Return True if path is a directory. Parameters ---------- path : str Path to check. DaskFileSystem Return True if path is a directory. Parameters ---------- path : str Path to check. S3FSWrapper Return True if path is a directory. Parameters ---------- path : str Path to check. HadoopFileSystem Return True if path is a directory. Parameters ---------- path : str Path to check. ``` Note that `FileSystem.isdir.__doc__` is not dedented because it does not use the `@ doc` decorator. ### Are there any user-facing changes? No * Closes: apache#34868 Authored-by: Dane Pitkin <dane@voltrondata.com> Signed-off-by: Alenka Frim <frim.alenka@gmail.com>
- Loading branch information
1 parent
f4bd43d
commit cd14e20
Showing
5 changed files
with
294 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.