diff --git a/PKG-INFO b/PKG-INFO index 5ee2cbc580bc4136db6dfd83204892e08460e5e7..d32ec1c75daab61a182ea73fadc761ef17c01594 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 0.0.54 +Version: 0.0.55 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers diff --git a/swh.model.egg-info/PKG-INFO b/swh.model.egg-info/PKG-INFO index 5ee2cbc580bc4136db6dfd83204892e08460e5e7..d32ec1c75daab61a182ea73fadc761ef17c01594 100644 --- a/swh.model.egg-info/PKG-INFO +++ b/swh.model.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: swh.model -Version: 0.0.54 +Version: 0.0.55 Summary: Software Heritage data model Home-page: https://forge.softwareheritage.org/diffusion/DMOD/ Author: Software Heritage developers diff --git a/swh/model/hypothesis_strategies.py b/swh/model/hypothesis_strategies.py index 5433b2a7a80940da091173bb5ad5627b52361ca9..8d3923c76536fe7f0888b7e8be14693f9002f6a9 100644 --- a/swh/model/hypothesis_strategies.py +++ b/swh/model/hypothesis_strategies.py @@ -153,7 +153,7 @@ def skipped_contents(draw): return draw(builds( SkippedContent, - length=optional(integers(min_value=0, max_value=2**63-1)), + length=integers(min_value=-1, max_value=2**63-1), sha1=optional(sha1()), sha1_git=optional(sha1_git()), sha256=optional(binary(min_size=32, max_size=32)), diff --git a/swh/model/model.py b/swh/model/model.py index 8a60f1812ba61b0fb57ec49df774e44dbb2f2f65..2a2eda27e398bc3c38242f620064f0e27167a048 100644 --- a/swh/model/model.py +++ b/swh/model/model.py @@ -396,6 +396,7 @@ class Content(BaseContent): status = attr.ib( type=str, + default='visible', validator=attr.validators.in_(['visible', 'hidden'])) data = attr.ib(type=Optional[bytes], default=None) @@ -406,7 +407,7 @@ class Content(BaseContent): @length.validator def check_length(self, attribute, value): """Checks the length is positive.""" - if self.status != 'absent' and value < 0: + if value < 0: raise ValueError('Length must be positive.') def to_dict(self): @@ -427,7 +428,7 @@ class SkippedContent(BaseContent): sha256 = attr.ib(type=Optional[bytes]) blake2s256 = attr.ib(type=Optional[bytes]) - length = attr.ib(type=Optional[int]) + length = attr.ib(type=int) status = attr.ib( type=str, @@ -451,7 +452,7 @@ class SkippedContent(BaseContent): @length.validator def check_length(self, attribute, value): """Checks the length is positive or -1.""" - if value is not None and value < -1: + if value < -1: raise ValueError('Length must be positive or -1.') def to_dict(self): diff --git a/version.txt b/version.txt index 9850c6e9f76ad31a4c57bff3ef34290a1b289bc5..8c5743b4feeccce19dee1a30d4bdd0e9413b8064 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v0.0.54-0-g8ebbd21 \ No newline at end of file +v0.0.55-0-g73053a6 \ No newline at end of file