Skip to content

Commit 15b2ac6

Browse files
committed
refactor: rename repr_mimebundle helpers and improve fallback comments
1 parent 1b7952b commit 15b2ac6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

bigframes/display/html.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def create_html_representation(
115115
from bigframes.series import Series
116116

117117
if isinstance(obj, Series):
118-
# Fallback to pandas string representation if the object is not a Series.
119-
# This protects against cases where obj might be something else unexpectedly,
120-
# or if the pandas Series implementation changes.
118+
# Some pandas objects may not have a _repr_html_ method, or it might
119+
# fail in certain environments. We fall back to a pre-formatted
120+
# string representation to ensure something is always displayed.
121121
pd_series = pandas_df.iloc[:, 0]
122122
try:
123123
html_string = pd_series._repr_html_()
@@ -226,7 +226,7 @@ def get_anywidget_bundle(
226226
return widget_repr, widget_metadata
227227

228228

229-
def _repr_mimebundle_deferred(
229+
def repr_mimebundle_deferred(
230230
obj: Union[bigframes.dataframe.DataFrame, bigframes.series.Series],
231231
) -> dict[str, str]:
232232
return {
@@ -235,7 +235,7 @@ def _repr_mimebundle_deferred(
235235
}
236236

237237

238-
def _repr_mimebundle_head(
238+
def repr_mimebundle_head(
239239
obj: Union[bigframes.dataframe.DataFrame, bigframes.series.Series],
240240
) -> dict[str, str]:
241241
from bigframes.series import Series
@@ -280,7 +280,7 @@ def repr_mimebundle(
280280

281281
opts = options.display
282282
if opts.repr_mode == "deferred":
283-
return _repr_mimebundle_deferred(obj)
283+
return repr_mimebundle_deferred(obj)
284284

285285
if opts.repr_mode == "anywidget":
286286
try:
@@ -295,4 +295,4 @@ def repr_mimebundle(
295295
f"Falling back to static HTML. Error: {traceback.format_exc()}"
296296
)
297297

298-
return _repr_mimebundle_head(obj)
298+
return repr_mimebundle_head(obj)

0 commit comments

Comments
 (0)