Skip to content
Snippets Groups Projects
Commit 86e049ed authored by Jenkins for Software Heritage's avatar Jenkins for Software Heritage
Browse files

New upstream version 0.3.0

parents 98d08848 3d9f6944
No related branches found
Tags debian/upstream/0.3.0
No related merge requests found
Metadata-Version: 2.1
Name: swh.model
Version: 0.2.2
Version: 0.3.0
Summary: Software Heritage data model
Home-page: https://forge.softwareheritage.org/diffusion/DMOD/
Author: Software Heritage developers
......
......@@ -3,7 +3,7 @@
# dependency lines, see https://pip.readthedocs.org/en/1.1/requirements.html
vcversioner
attrs
attrs_strict
attrs_strict >= 0.0.7
hypothesis
python-dateutil
iso8601
Metadata-Version: 2.1
Name: swh.model
Version: 0.2.2
Version: 0.3.0
Summary: Software Heritage data model
Home-page: https://forge.softwareheritage.org/diffusion/DMOD/
Author: Software Heritage developers
......
vcversioner
attrs
attrs_strict
attrs_strict>=0.0.7
hypothesis
python-dateutil
iso8601
......
......@@ -18,12 +18,12 @@ from hypothesis.strategies import (
from_regex,
integers,
just,
lists,
none,
one_of,
sampled_from,
sets,
text,
tuples,
)
from .from_disk import DentryPerms
......@@ -240,7 +240,7 @@ def revisions_d():
committer=persons_d(),
date=timestamps_with_timezone_d(),
committer_date=timestamps_with_timezone_d(),
parents=lists(sha1_git()),
parents=tuples(sha1_git()),
directory=sha1_git(),
type=sampled_from([x.value for x in RevisionType]),
metadata=one_of(none(), revision_metadata()),
......@@ -267,7 +267,7 @@ def directory_entries():
def directories_d():
return builds(dict, entries=lists(directory_entries_d()))
return builds(dict, entries=tuples(directory_entries_d()))
def directories():
......
......@@ -8,7 +8,7 @@ import datetime
from abc import ABCMeta, abstractmethod
from enum import Enum
from hashlib import sha256
from typing import Dict, List, Optional, TypeVar, Union
from typing import Dict, Optional, Tuple, TypeVar, Union
import attr
from attrs_strict import type_validator
......@@ -46,8 +46,8 @@ def dictify(value):
return value.value
elif isinstance(value, dict):
return {k: dictify(v) for k, v in value.items()}
elif isinstance(value, list):
return [dictify(v) for v in value]
elif isinstance(value, tuple):
return tuple(dictify(v) for v in value)
else:
return value
......@@ -420,9 +420,7 @@ class Revision(BaseModel, HashableObject):
metadata = attr.ib(
type=Optional[Dict[str, object]], validator=type_validator(), default=None
)
parents = attr.ib(
type=List[Sha1Git], validator=type_validator(), default=attr.Factory(list)
)
parents = attr.ib(type=Tuple[Sha1Git, ...], validator=type_validator(), default=())
id = attr.ib(type=Sha1Git, validator=type_validator(), default=b"")
@staticmethod
......@@ -446,6 +444,7 @@ class Revision(BaseModel, HashableObject):
date=date,
committer_date=committer_date,
type=RevisionType(d.pop("type")),
parents=tuple(d.pop("parents")), # for BW compat
**d,
)
......@@ -471,7 +470,7 @@ class DirectoryEntry(BaseModel):
@attr.s(frozen=True)
class Directory(BaseModel, HashableObject):
entries = attr.ib(type=List[DirectoryEntry], validator=type_validator())
entries = attr.ib(type=Tuple[DirectoryEntry, ...], validator=type_validator())
id = attr.ib(type=Sha1Git, validator=type_validator(), default=b"")
@staticmethod
......@@ -482,7 +481,10 @@ class Directory(BaseModel, HashableObject):
def from_dict(cls, d):
d = d.copy()
return cls(
entries=[DirectoryEntry.from_dict(entry) for entry in d.pop("entries")], **d
entries=tuple(
DirectoryEntry.from_dict(entry) for entry in d.pop("entries")
),
**d,
)
......
......@@ -66,7 +66,7 @@ def assert_nested_dict(obj):
for (key, value) in obj.items():
assert isinstance(key, (str, bytes)), key
assert_nested_dict(value)
elif isinstance(obj, list):
elif isinstance(obj, tuple):
for value in obj:
assert_nested_dict(value)
elif isinstance(obj, (int, float, str, bytes, bool, type(None), datetime.datetime)):
......
v0.2.2-0-g340656d
\ No newline at end of file
v0.3.0-0-g3d9f694
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment