Skip to content
Merged
Changes from 1 commit
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
25 changes: 19 additions & 6 deletions bigframes/display/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@

from __future__ import annotations

try:
import anywidget # noqa
from typing import Any

from bigframes.display.anywidget import TableWidget

__all__ = ["TableWidget"]
except Exception:
pass
def __getattr__(name: str) -> Any:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't typical to do, so could you please add some comments explaining why we defer in this way in the docstring and/or comments as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for suggestion. I add docstring.

if name == "TableWidget":
try:
import anywidget # noqa

from bigframes.display.anywidget import TableWidget

return TableWidget
except Exception:
raise AttributeError(
f"module '{__name__}' has no attribute '{name}'. "
"TableWidget requires anywidget and traitlets to be installed. "
"Please `pip install anywidget traitlets` or `pip install 'bigframes[anywidget]'`."
)
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")


__all__ = ["TableWidget"]