mirror of
https://github.com/clearml/clearml
synced 2025-01-31 00:56:57 +00:00
Fix attrs.__version__ deprecation warning (#1145)
This commit is contained in:
parent
ecdeb2d0a2
commit
68aa2a9e9e
@ -2,12 +2,19 @@ import attr
|
||||
|
||||
from .version import Version
|
||||
|
||||
try:
|
||||
# noinspection PyUnresolvedReferences
|
||||
import importlib.metadata
|
||||
attr_version = importlib.metadata.version("attrs")
|
||||
except ImportError:
|
||||
attr_version = attr.__version__
|
||||
|
||||
|
||||
class attrs(object):
|
||||
def __init__(self, *args, **kwargs):
|
||||
if any(x in kwargs for x in ("eq", "order")):
|
||||
raise RuntimeError("Only `cmp` is supported for attr.attrs, not `eq` or `order`")
|
||||
if Version(attr.__version__) >= Version("19.2"):
|
||||
if Version(attr_version) >= Version("19.2"):
|
||||
cmp = kwargs.pop("cmp", None)
|
||||
if cmp is not None:
|
||||
kwargs["eq"] = kwargs["order"] = cmp
|
||||
|
Loading…
Reference in New Issue
Block a user