From 43e0b33f5aac47665769f316c4be1845ef76bfb7 Mon Sep 17 00:00:00 2001 From: Joscha Schmiedt <joscha@schmiedt.dev> Date: Wed, 10 Apr 2024 22:17:34 +0200 Subject: [PATCH] Allow None for Version.is_head and Version.is_complete_history --- src/linkahead/common/versioning.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/linkahead/common/versioning.py b/src/linkahead/common/versioning.py index beced57a..ea4fe3e7 100644 --- a/src/linkahead/common/versioning.py +++ b/src/linkahead/common/versioning.py @@ -103,8 +103,8 @@ class Version(): def __init__(self, id: Optional[str] = None, date: Optional[str] = None, username: Optional[str] = None, realm: Optional[str] = None, predecessors: Optional[List[Version]] = None, successors: Optional[List[Version]] = None, - is_head: Union[bool, str] = False, - is_complete_history: Union[bool, str] = False): + is_head: Union[bool, str, None] = False, + is_complete_history: Union[bool, str, None] = False): """Typically the `predecessors` or `successors` should not "link back" to an existing Version object.""" self.id = id @@ -210,18 +210,9 @@ object.""" p) for p in xml if p.tag.lower() == "predecessor"] successors = [Version.from_xml(s) for s in xml if s.tag.lower() == "successor"] - is_head = xml.get("head") - if is_head is None: - raise ValueError(f"Version head is missing from xml:{str(xml)}") - - is_complete_history = xml.get("completeHistory") - if is_complete_history is None: - raise ValueError( - f"Version completeHistory is missing from xml:{str(xml)}") - return Version(id=xml.get("id"), date=xml.get("date"), - is_head=is_head, - is_complete_history=is_complete_history, + is_head=xml.get("head"), + is_complete_history=xml.get("completeHistory"), username=xml.get("username"), realm=xml.get("realm"), predecessors=predecessors, successors=successors) -- GitLab