mirror of
https://github.com/clearml/clearml
synced 2025-01-31 17:17:00 +00:00
23 lines
639 B
Python
23 lines
639 B
Python
import attr
|
|
|
|
from .version import 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"):
|
|
cmp = kwargs.pop("cmp", None)
|
|
if cmp is not None:
|
|
kwargs["eq"] = kwargs["order"] = cmp
|
|
self.args = args
|
|
self.kwargs = kwargs
|
|
|
|
def __call__(self, f):
|
|
return attr.attrs(*self.args, **self.kwargs)(f)
|
|
|
|
|
|
def readonly(value):
|
|
return property(lambda self: value)
|