Skip to content
Snippets Groups Projects
Commit 43e0b33f authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Allow None for Version.is_head and Version.is_complete_history

parent e23a9087
No related branches found
No related tags found
2 merge requests!143Release 0.15.0,!135Add and fix more type hints
......@@ -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)
......
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