Commits


Dane Pitkin authored and GitHub committed cd14e2019ce
GH-34868: [Python] Share docstrings between classes (#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 https://github.com/python/cpython/issues/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: #34868 Authored-by: Dane Pitkin <dane@voltrondata.com> Signed-off-by: Alenka Frim <frim.alenka@gmail.com>