Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/bigframes/bigframes/_tools/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def decorator(target_class):
if hasattr(source_item, "__doc__") and source_item.__doc__:
try:
target_item.__doc__ = source_item.__doc__
if isinstance(target_item, property) and target_item.fget:
try:
target_item.fget.__doc__ = source_item.__doc__
except AttributeError:
pass
except AttributeError:
pass
Comment on lines 32 to 40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

If target_item.__doc__ = source_item.__doc__ raises an AttributeError (which can happen for certain read-only descriptors like classmethod or staticmethod in some Python versions), the execution jumps directly to the outer except AttributeError block, skipping the logic to set the docstring on the underlying getter or function.

To make this decorator more robust and reusable across the codebase, we should:

  1. Separate the docstring assignment of the descriptor itself from the assignment of the underlying callable.
  2. Extend support to other common descriptors like classmethod/staticmethod (which wrap functions in __func__) and cached_property (which wrap functions in func).
Suggested change
try:
target_item.__doc__ = source_item.__doc__
if isinstance(target_item, property) and target_item.fget:
try:
target_item.fget.__doc__ = source_item.__doc__
except AttributeError:
pass
except AttributeError:
pass
try:
target_item.__doc__ = source_item.__doc__
except AttributeError:
pass
underlying = None
if isinstance(target_item, property):
underlying = target_item.fget
elif hasattr(target_item, "__func__"):
underlying = target_item.__func__
elif hasattr(target_item, "func"):
underlying = getattr(target_item, "func", None)
if underlying is not None:
try:
underlying.__doc__ = source_item.__doc__
except AttributeError:
pass


Expand Down
2 changes: 2 additions & 0 deletions packages/bigframes/bigframes/pandas/api/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@
from bigframes.core.groupby.series_group_by import SeriesGroupBy
from bigframes.core.window import Window
from bigframes.operations.datetimes import DatetimeMethods
from bigframes.operations.plotting import PlotAccessor
from bigframes.operations.strings import StringMethods
from bigframes.operations.structs import StructAccessor, StructFrameAccessor

__all__ = [
"DataFrameGroupBy",
"DatetimeMethods",
"PlotAccessor",
"SeriesGroupBy",
"StringMethods",
"StructAccessor",
Expand Down
4 changes: 2 additions & 2 deletions packages/bigframes/docs/templates/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
- name: DataFrame
uid: bigframes.dataframe.DataFrame
- name: PlotAccessor
uid: bigframes.operations.plotting.PlotAccessor
uid: bigframes.pandas.api.typing.PlotAccessor
- name: StructAccessor
uid: bigframes.operations.structs.StructFrameAccessor
name: DataFrame
Expand Down Expand Up @@ -86,7 +86,7 @@
- name: ListAccessor
uid: bigframes.operations.lists.ListAccessor
- name: PlotAccessor
uid: bigframes.operations.plotting.PlotAccessor
uid: bigframes.pandas.api.typing.PlotAccessor
name: Series
- name: Window
uid: bigframes.core.window.Window
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7335,7 +7335,7 @@ def plot(self):
Make plots of Dataframes.

Returns:
bigframes.operations.plotting.PlotAccessor:
bigframes.pandas.api.typing.PlotAccessor:
An accessor making plots.
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5450,7 +5450,7 @@ def plot(self):
<Axes: title={'center': 'My plot'}, ylabel='Frequency'>

Returns:
bigframes.operations.plotting.PlotAccessor:
bigframes.pandas.api.typing.PlotAccessor:
An accessor making plots.
"""
raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)
Expand Down
Loading