Skip to content

Commit 34adb55

Browse files
authored
Merge pull request #5177 from plotly/remove-kaleido-deprecation-warnings
Disable Kaleido deprecation warnings
2 parents 058eed2 + 61bb76c commit 34adb55

File tree

3 files changed

+134
-113
lines changed

3 files changed

+134
-113
lines changed

plotly/basedatatypes.py

+49-45
Original file line numberDiff line numberDiff line change
@@ -3740,29 +3740,29 @@ def to_image(self, *args, **kwargs):
37403740
- 'webp'
37413741
- 'svg'
37423742
- 'pdf'
3743-
- 'eps' (deprecated) (Requires the poppler library to be installed)
3743+
- 'eps' (Kaleido v0.* only) (Requires the poppler library to be installed)
37443744
37453745
If not specified, will default to:
3746-
- `plotly.io.defaults.default_format` if engine is "kaleido"
3747-
- `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
3746+
- `plotly.io.defaults.default_format` or `plotly.io.kaleido.scope.default_format` if engine is "kaleido"
3747+
- `plotly.io.orca.config.default_format` if engine is "orca"
37483748
37493749
width: int or None
37503750
The width of the exported image in layout pixels. If the `scale`
37513751
property is 1.0, this will also be the width of the exported image
37523752
in physical pixels.
37533753
37543754
If not specified, will default to:
3755-
- `plotly.io.defaults.default_width` if engine is "kaleido"
3756-
- `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
3755+
- `plotly.io.defaults.default_width` or `plotly.io.kaleido.scope.default_width` if engine is "kaleido"
3756+
- `plotly.io.orca.config.default_width` if engine is "orca"
37573757
37583758
height: int or None
37593759
The height of the exported image in layout pixels. If the `scale`
37603760
property is 1.0, this will also be the height of the exported image
37613761
in physical pixels.
37623762
37633763
If not specified, will default to:
3764-
- `plotly.io.defaults.default_height` if engine is "kaleido"
3765-
- `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
3764+
- `plotly.io.defaults.default_height` or `plotly.io.kaleido.scope.default_height` if engine is "kaleido"
3765+
- `plotly.io.orca.config.default_height` if engine is "orca"
37663766
37673767
scale: int or float or None
37683768
The scale factor to use when exporting the figure. A scale factor
@@ -3771,14 +3771,14 @@ def to_image(self, *args, **kwargs):
37713771
less than 1.0 will decrease the image resolution.
37723772
37733773
If not specified, will default to:
3774-
- `plotly.io.defaults.default_scale` if engine is "kaliedo"
3775-
- `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)
3774+
- `plotly.io.defaults.default_scale` or `plotly.io.kaleido.scope.default_scale` if engine is "kaliedo"
3775+
- `plotly.io.orca.config.default_scale` if engine is "orca"
37763776
37773777
validate: bool
37783778
True if the figure should be validated before being converted to
37793779
an image, False otherwise.
37803780
3781-
engine (deprecated): str
3781+
engine: str
37823782
Image export engine to use. This parameter is deprecated and Orca engine support will be
37833783
dropped in the next major Plotly version. Until then, the following values are supported:
37843784
- "kaleido": Use Kaleido for image export
@@ -3794,23 +3794,25 @@ def to_image(self, *args, **kwargs):
37943794
from plotly.io.kaleido import (
37953795
kaleido_available,
37963796
kaleido_major,
3797+
ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS,
37973798
KALEIDO_DEPRECATION_MSG,
37983799
ORCA_DEPRECATION_MSG,
37993800
ENGINE_PARAM_DEPRECATION_MSG,
38003801
)
38013802

3802-
if (
3803-
kwargs.get("engine", None) in {None, "auto", "kaleido"}
3804-
and kaleido_available()
3805-
and kaleido_major() < 1
3806-
):
3807-
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3808-
if kwargs.get("engine", None) == "orca":
3809-
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3810-
if kwargs.get("engine", None):
3811-
warnings.warn(
3812-
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
3813-
)
3803+
if ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS:
3804+
if (
3805+
kwargs.get("engine", None) in {None, "auto", "kaleido"}
3806+
and kaleido_available()
3807+
and kaleido_major() < 1
3808+
):
3809+
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3810+
if kwargs.get("engine", None) == "orca":
3811+
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3812+
if kwargs.get("engine", None):
3813+
warnings.warn(
3814+
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
3815+
)
38143816

38153817
return pio.to_image(self, *args, **kwargs)
38163818

@@ -3832,31 +3834,31 @@ def write_image(self, *args, **kwargs):
38323834
- 'webp'
38333835
- 'svg'
38343836
- 'pdf'
3835-
- 'eps' (deprecated) (Requires the poppler library to be installed)
3837+
- 'eps' (Kaleido v0.* only) (Requires the poppler library to be installed)
38363838
38373839
If not specified and `file` is a string then this will default to the
38383840
file extension. If not specified and `file` is not a string then this
38393841
will default to:
3840-
- `plotly.io.defaults.default_format` if engine is "kaleido"
3841-
- `plotly.io.orca.config.default_format` if engine is "orca" (deprecated)
3842+
- `plotly.io.defaults.default_format` or `plotly.io.kaleido.scope.default_format` if engine is "kaleido"
3843+
- `plotly.io.orca.config.default_format` if engine is "orca"
38423844
38433845
width: int or None
38443846
The width of the exported image in layout pixels. If the `scale`
38453847
property is 1.0, this will also be the width of the exported image
38463848
in physical pixels.
38473849
38483850
If not specified, will default to:
3849-
- `plotly.io.defaults.default_width` if engine is "kaleido"
3850-
- `plotly.io.orca.config.default_width` if engine is "orca" (deprecated)
3851+
- `plotly.io.defaults.default_width` or `plotly.io.kaleido.scope.default_width` if engine is "kaleido"
3852+
- `plotly.io.orca.config.default_width` if engine is "orca"
38513853
38523854
height: int or None
38533855
The height of the exported image in layout pixels. If the `scale`
38543856
property is 1.0, this will also be the height of the exported image
38553857
in physical pixels.
38563858
38573859
If not specified, will default to:
3858-
- `plotly.io.defaults.default_height` if engine is "kaleido"
3859-
- `plotly.io.orca.config.default_height` if engine is "orca" (deprecated)
3860+
- `plotly.io.defaults.default_height` or `plotly.io.kaleido.scope.default_height` if engine is "kaleido"
3861+
- `plotly.io.orca.config.default_height` if engine is "orca"
38603862
38613863
scale: int or float or None
38623864
The scale factor to use when exporting the figure. A scale factor
@@ -3865,14 +3867,14 @@ def write_image(self, *args, **kwargs):
38653867
less than 1.0 will decrease the image resolution.
38663868
38673869
If not specified, will default to:
3868-
- `plotly.io.defaults.default_scale` if engine is "kaleido"
3869-
- `plotly.io.orca.config.default_scale` if engine is "orca" (deprecated)
3870+
- `plotly.io.defaults.default_scale` or `plotly.io.kaleido.scope.default_scale` if engine is "kaleido"
3871+
- `plotly.io.orca.config.default_scale` if engine is "orca"
38703872
38713873
validate: bool
38723874
True if the figure should be validated before being converted to
38733875
an image, False otherwise.
38743876
3875-
engine (deprecated): str
3877+
engine: str
38763878
Image export engine to use. This parameter is deprecated and Orca engine support will be
38773879
dropped in the next major Plotly version. Until then, the following values are supported:
38783880
- "kaleido": Use Kaleido for image export
@@ -3887,24 +3889,26 @@ def write_image(self, *args, **kwargs):
38873889
from plotly.io.kaleido import (
38883890
kaleido_available,
38893891
kaleido_major,
3892+
ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS,
38903893
KALEIDO_DEPRECATION_MSG,
38913894
ORCA_DEPRECATION_MSG,
38923895
ENGINE_PARAM_DEPRECATION_MSG,
38933896
)
38943897

3895-
if (
3896-
kwargs.get("engine", None) in {None, "auto", "kaleido"}
3897-
and kaleido_available()
3898-
and kaleido_major() < 1
3899-
):
3900-
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3901-
if kwargs.get("engine", None) == "orca":
3902-
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3903-
if kwargs.get("engine", None):
3904-
warnings.warn(
3905-
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
3906-
)
3907-
return pio.write_image(self, *args, **kwargs)
3898+
if ENABLE_KALEIDO_V0_DEPRECATION_WARNINGS:
3899+
if (
3900+
kwargs.get("engine", None) in {None, "auto", "kaleido"}
3901+
and kaleido_available()
3902+
and kaleido_major() < 1
3903+
):
3904+
warnings.warn(KALEIDO_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3905+
if kwargs.get("engine", None) == "orca":
3906+
warnings.warn(ORCA_DEPRECATION_MSG, DeprecationWarning, stacklevel=2)
3907+
if kwargs.get("engine", None):
3908+
warnings.warn(
3909+
ENGINE_PARAM_DEPRECATION_MSG, DeprecationWarning, stacklevel=2
3910+
)
3911+
return pio.write_image(self, *args, **kwargs)
39083912

39093913
# Static helpers
39103914
# --------------

0 commit comments

Comments
 (0)