From ad31004aefd56322794b83515b50702d77d67da4 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Thu, 30 May 2019 12:06:17 -0400 Subject: [PATCH 1/2] RF: revert to default cmp=True for attr.s. Rely on frozen to get hash generated --- reproman/distributions/debian.py | 4 ++-- reproman/distributions/docker.py | 2 +- reproman/distributions/redhat.py | 2 +- reproman/distributions/singularity.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/reproman/distributions/debian.py b/reproman/distributions/debian.py index 6c9ad9b35..b1de5c102 100644 --- a/reproman/distributions/debian.py +++ b/reproman/distributions/debian.py @@ -52,7 +52,7 @@ # TODO: flyweight/singleton ? # To make them hashable we need to freeze them... not sure if we are ready: #@attr.s(cmp=True, hash=True, frozen=True) -@attr.s(cmp=True) +@attr.s class APTSource(SpecObject): """APT origin information """ @@ -69,7 +69,7 @@ class APTSource(SpecObject): _register_with_representer(APTSource) -@attr.s(slots=True, frozen=True, cmp=False, hash=True) +@attr.s(slots=True, frozen=True, hash=True) class DEBPackage(Package): """Debian package information""" name = attrib(default=attr.NOTHING) diff --git a/reproman/distributions/docker.py b/reproman/distributions/docker.py index 9007db011..6938eb066 100644 --- a/reproman/distributions/docker.py +++ b/reproman/distributions/docker.py @@ -23,7 +23,7 @@ from ..utils import attrib -@attr.s(slots=True, frozen=True, cmp=False, hash=True) +@attr.s(slots=True, frozen=True, hash=True) class DockerImage(Package): """Docker image information""" id = attrib(default=attr.NOTHING) diff --git a/reproman/distributions/redhat.py b/reproman/distributions/redhat.py index 8f7baf0c4..5f5e13476 100644 --- a/reproman/distributions/redhat.py +++ b/reproman/distributions/redhat.py @@ -45,7 +45,7 @@ class RPMSource(SpecObject): _register_with_representer(RPMSource) -@attr.s(slots=True, frozen=True, cmp=False, hash=True) +@attr.s(slots=True, frozen=True, hash=True) class RPMPackage(Package): """Redhat package information""" name = attrib(default=attr.NOTHING) diff --git a/reproman/distributions/singularity.py b/reproman/distributions/singularity.py index 972443cc9..88394247b 100644 --- a/reproman/distributions/singularity.py +++ b/reproman/distributions/singularity.py @@ -26,7 +26,7 @@ from ..utils import attrib, md5sum, chpwd -@attr.s(slots=True, frozen=True, cmp=False, hash=True) +@attr.s(slots=True, frozen=True, hash=True) class SingularityImage(Package): """Singularity image information""" md5 = attrib(default=attr.NOTHING) From fae7a7edf0013248a55fa585e244ee6b57448103 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 17 Jun 2019 10:36:14 -0400 Subject: [PATCH 2/2] RF: remove explicit hash=True from @attr.s See https://github.com/ReproNim/reproman/pull/430#issuecomment-499493823 for more reasoning -- objects should still be hashable --- reproman/distributions/debian.py | 4 ++-- reproman/distributions/docker.py | 2 +- reproman/distributions/redhat.py | 2 +- reproman/distributions/singularity.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/reproman/distributions/debian.py b/reproman/distributions/debian.py index b1de5c102..776aae9c2 100644 --- a/reproman/distributions/debian.py +++ b/reproman/distributions/debian.py @@ -51,7 +51,7 @@ # TODO: flyweight/singleton ? # To make them hashable we need to freeze them... not sure if we are ready: -#@attr.s(cmp=True, hash=True, frozen=True) +#@attr.s(cmp=True, frozen=True) @attr.s class APTSource(SpecObject): """APT origin information @@ -69,7 +69,7 @@ class APTSource(SpecObject): _register_with_representer(APTSource) -@attr.s(slots=True, frozen=True, hash=True) +@attr.s(slots=True, frozen=True) class DEBPackage(Package): """Debian package information""" name = attrib(default=attr.NOTHING) diff --git a/reproman/distributions/docker.py b/reproman/distributions/docker.py index 6938eb066..baa7e1ec1 100644 --- a/reproman/distributions/docker.py +++ b/reproman/distributions/docker.py @@ -23,7 +23,7 @@ from ..utils import attrib -@attr.s(slots=True, frozen=True, hash=True) +@attr.s(slots=True, frozen=True) class DockerImage(Package): """Docker image information""" id = attrib(default=attr.NOTHING) diff --git a/reproman/distributions/redhat.py b/reproman/distributions/redhat.py index 5f5e13476..cec4b61c4 100644 --- a/reproman/distributions/redhat.py +++ b/reproman/distributions/redhat.py @@ -45,7 +45,7 @@ class RPMSource(SpecObject): _register_with_representer(RPMSource) -@attr.s(slots=True, frozen=True, hash=True) +@attr.s(slots=True, frozen=True) class RPMPackage(Package): """Redhat package information""" name = attrib(default=attr.NOTHING) diff --git a/reproman/distributions/singularity.py b/reproman/distributions/singularity.py index 88394247b..c99ce49a4 100644 --- a/reproman/distributions/singularity.py +++ b/reproman/distributions/singularity.py @@ -26,7 +26,7 @@ from ..utils import attrib, md5sum, chpwd -@attr.s(slots=True, frozen=True, hash=True) +@attr.s(slots=True, frozen=True) class SingularityImage(Package): """Singularity image information""" md5 = attrib(default=attr.NOTHING)