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

Updated distutils.Version to packaging.Version #3897

Merged
merged 2 commits into from
Jan 31, 2023
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions packages/python/plotly/plotly/graph_objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@
if sys.version_info < (3, 7) or TYPE_CHECKING:
try:
import ipywidgets as _ipywidgets
from distutils.version import LooseVersion as _LooseVersion
from packaging.version import Version as _Version

if _LooseVersion(_ipywidgets.__version__) >= _LooseVersion("7.0.0"):
if _Version(_ipywidgets.__version__) >= _Version("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget
else:
raise ImportError()
Expand All @@ -283,9 +283,9 @@ def __getattr__(import_name):
if import_name == "FigureWidget":
try:
import ipywidgets
from distutils.version import LooseVersion
from packaging.version import Version

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

return FigureWidget
Expand Down
8 changes: 4 additions & 4 deletions packages/python/plotly/plotly/graph_objs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,9 @@
if sys.version_info < (3, 7) or TYPE_CHECKING:
try:
import ipywidgets as _ipywidgets
from distutils.version import LooseVersion as _LooseVersion
from packaging.version import Version as _Version

if _LooseVersion(_ipywidgets.__version__) >= _LooseVersion("7.0.0"):
if _Version(_ipywidgets.__version__) >= _Version("7.0.0"):
from ..graph_objs._figurewidget import FigureWidget
else:
raise ImportError()
Expand All @@ -283,9 +283,9 @@ def __getattr__(import_name):
if import_name == "FigureWidget":
try:
import ipywidgets
from distutils.version import LooseVersion
from packaging.version import Version

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

return FigureWidget
Expand Down
4 changes: 2 additions & 2 deletions packages/python/plotly/plotly/io/_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from copy import copy

import os
from distutils.version import LooseVersion
from packaging.version import Version

from plotly import optional_imports

Expand Down Expand Up @@ -392,7 +392,7 @@ def show(fig, renderer=None, validate=True, **kwargs):
"Mime type rendering requires ipython but it is not installed"
)

if not nbformat or LooseVersion(nbformat.__version__) < LooseVersion("4.2.0"):
if not nbformat or Version(nbformat.__version__) < Version("4.2.0"):
raise ValueError(
"Mime type rendering requires nbformat>=4.2.0 but it is not installed"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings
import itertools
from contextlib import contextmanager
from distutils.version import LooseVersion
from packaging.version import Version

import numpy as np
import matplotlib as mpl
Expand Down Expand Up @@ -199,7 +199,7 @@ def _iter_path_collection(paths, path_transforms, offsets, styles):

# Before mpl 1.4.0, path_transform can be a false-y value, not a valid
# transformation matrix.
if LooseVersion(mpl.__version__) < LooseVersion("1.4.0"):
if Version(mpl.__version__) < Version("1.4.0"):
if path_transforms is None:
path_transforms = [np.eye(3)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import matplotlib
import numpy as np
from distutils.version import LooseVersion
import pytest
from numpy.testing import assert_warns
from packaging.version import Version

from ..exporter import Exporter
from ..renderers import FakeRenderer, FullFakeRenderer
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_multiaxes():
def test_image():
# Test fails for matplotlib 1.5+ because the size of the image
# generated by matplotlib has changed.
if LooseVersion(matplotlib.__version__) == LooseVersion("3.4.1"):
if Version(matplotlib.__version__) == Version("3.4.1"):
image_size = 432
else:
pytest.skip("Test fails for older matplotlib")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

try:
import ipywidgets as _ipywidgets
from distutils.version import LooseVersion as _LooseVersion
from packaging.version import Version as _Version

if _LooseVersion(_ipywidgets.__version__) >= _LooseVersion("7.0.0"):
if _Version(_ipywidgets.__version__) >= _Version("7.0.0"):
missing_ipywidgets = False
else:
raise ImportError()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import plotly.io as pio
import subprocess
import os
from distutils.version import LooseVersion
from packaging.version import Version
import requests
import time
import psutil
Expand Down Expand Up @@ -79,11 +79,11 @@ def test_orca_executable_path():
def test_orca_version_number():
assert pio.orca.status.version is None

expected_min = LooseVersion("1.1.0")
expected_max = LooseVersion("2.0.0")
expected_min = Version("1.1.0")
expected_max = Version("2.0.0")

pio.orca.validate_executable()
version = LooseVersion(pio.orca.status.version)
version = Version(pio.orca.status.version)

assert expected_min <= version
assert version < expected_max
Expand Down
6 changes: 2 additions & 4 deletions packages/python/plotly/plotly/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ def stable_semver():

'3.0.0rc11' -> '3.0.0'
"""
from distutils.version import LooseVersion
from packaging.version import Version

version_components = LooseVersion(__version__).version
stable_ver_str = ".".join(str(s) for s in version_components[0:3])
return stable_ver_str
return Version(__version__).base_version