Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove duplicate FigureWidget code in graph_objects #3779

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
37 changes: 2 additions & 35 deletions packages/python/plotly/plotly/graph_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
from ..graph_objs import Layout
from ..graph_objs import Frame
from ..graph_objs import Figure
from ..graph_objs import FigureWidget
from ..graph_objs import Data
from ..graph_objs import Annotations
from ..graph_objs import Frames
Expand Down Expand Up @@ -235,6 +236,7 @@
"..graph_objs.Layout",
"..graph_objs.Frame",
"..graph_objs.Figure",
"..graph_objs.FigureWidget",
"..graph_objs.Data",
"..graph_objs.Annotations",
"..graph_objs.Frames",
Expand Down Expand Up @@ -262,38 +264,3 @@
"..graph_objs.Histogram2dcontour",
],
)


if sys.version_info < (3, 7) or TYPE_CHECKING:
try:
import ipywidgets as _ipywidgets
from distutils.version import LooseVersion as _LooseVersion

if _LooseVersion(_ipywidgets.__version__) >= _LooseVersion("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget
else:
raise ImportError()
except Exception:
from ..missing_ipywidgets import FigureWidget
else:
__all__.append("FigureWidget")
orig_getattr = __getattr__

def __getattr__(import_name):
if import_name == "FigureWidget":
try:
import ipywidgets
from distutils.version import LooseVersion

if LooseVersion(ipywidgets.__version__) >= LooseVersion("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget

return FigureWidget
else:
raise ImportError()
except Exception:
from ..missing_ipywidgets import FigureWidget

return FigureWidget

return orig_getattr(import_name)