Skip to content

Commit

Permalink
Deprecate distutils.version for removing warning info (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-tong authored Dec 27, 2022
1 parent 7293369 commit 72b31c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mim/click/compat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) OpenMMLab. All rights reserved.
from distutils.version import LooseVersion
from typing import Callable

import click
from pip._vendor.packaging import version


def autocompletion_to_shell_complete(autocompletion: Callable) -> Callable:
Expand Down Expand Up @@ -44,7 +44,7 @@ def argument(*param_decls, **attrs):
"""
# 'autocompletion' will be removed in Click 8.1 and its new name is
# 'shell_complete'.
if LooseVersion(click.__version__) >= LooseVersion('8.0.0'):
if version.parse(click.__version__) >= version.parse('8.0.0'):
autocompletion = attrs.pop('autocompletion', None)
if autocompletion is not None:
attrs['shell_complete'] = autocompletion_to_shell_complete(
Expand Down
4 changes: 2 additions & 2 deletions mim/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
import tarfile
import typing
from collections import defaultdict
from distutils.version import LooseVersion
from email.parser import FeedParser
from pkg_resources import get_distribution, parse_version
from typing import Any, List, Optional, Tuple, Union

import click
import requests
from pip._vendor.packaging import version
from requests.exceptions import InvalidURL, RequestException, Timeout
from requests.models import Response

Expand Down Expand Up @@ -285,7 +285,7 @@ def get_latest_version(package: str, timeout: int = 15) -> str:


def is_version_equal(version1: str, version2: str) -> bool:
return LooseVersion(version1) == LooseVersion(version2)
return version.parse(version1) == version.parse(version2)


@ensure_installation
Expand Down

0 comments on commit 72b31c0

Please sign in to comment.