1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
import warnings
import functools
# Initialize _future_flags with all future flags that are now always in
# effect.
_future_flags = {
"renderer_defaults",
"template_defaults",
"extract_chart_studio",
"remove_deprecations",
"v4_subplots",
"orca_defaults",
"timezones",
"trace_uids",
}
def _assert_plotly_not_imported():
import sys
if "plotly" in sys.modules:
raise ImportError(
"""\
The _plotly_future_ module must be imported before the plotly module"""
)
warnings.filterwarnings(
"default", ".*?is deprecated, please use chart_studio*", DeprecationWarning
)
def _chart_studio_warning(submodule):
warnings.warn(
"The plotly.{submodule} module is deprecated, "
"please use chart_studio.{submodule} instead".format(submodule=submodule),
DeprecationWarning,
stacklevel=2,
)
def _chart_studio_error(submodule):
raise ImportError(
"""
The plotly.{submodule} module is deprecated,
please install the chart-studio package and use the
chart_studio.{submodule} module instead.
""".format(
submodule=submodule
)
)
def _chart_studio_deprecation(fn):
fn_name = fn.__name__
fn_module = fn.__module__
plotly_name = ".".join(["plotly"] + fn_module.split(".")[1:] + [fn_name])
chart_studio_name = ".".join(
["chart_studio"] + fn_module.split(".")[1:] + [fn_name]
)
msg = """\
{plotly_name} is deprecated, please use {chart_studio_name}\
""".format(
plotly_name=plotly_name, chart_studio_name=chart_studio_name
)
@functools.wraps(fn)
def wrapper(*args, **kwargs):
warnings.warn(msg, DeprecationWarning, stacklevel=2)
return fn(*args, **kwargs)
return wrapper
__all__ = ["_future_flags", "_chart_studio_error"]
|