Skip to content

Commit

Permalink
Mark optional parameters as explicitly optional
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaslehnertum committed Jan 21, 2024
1 parent 39a7544 commit bd5b1c1
Showing 1 changed file with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from enum import Enum
from functools import reduce
from itertools import chain
from typing import Optional

DEFAULT_XSI_PREFIX = "xsi"
DEFAULT_BPMN_PREFIX = "bpmn"
Expand Down Expand Up @@ -32,7 +33,7 @@ class BPMNElementType(str, Enum):


class BPMNFlowType(str, Enum):
SEQUENCE = "sequence",
SEQUENCE = "sequence"
MESSAGE = "message"


Expand Down Expand Up @@ -219,7 +220,7 @@ def __prefix_tag(tag: str, prefix: str) -> str:
"""
return f"{prefix}:{tag}"

def __shorten_id(self, element_id: str, prefix: str = None) -> str:
def __shorten_id(self, element_id: str, prefix: Optional[str] = None) -> str:
"""
Prefix an element id with a given prefix.
If no prefix is provided, 'bpmn' is used as default.
Expand Down Expand Up @@ -251,7 +252,7 @@ def __get_flows_connected_to_element(flows: list[dict], element_id: str) -> list
"element") == element_id, flows))

def __serialize_base_element(self, element: dict, tag: str,
connected_flows: list[dict] = None) -> ElementTree.Element:
connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN flow to XML
:param element: A dictionary representing a BPMN flow element
Expand Down Expand Up @@ -281,7 +282,7 @@ def __serialize_base_element(self, element: dict, tag: str,

return serialized_element

def __serialize_annotation(self, annotation: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_annotation(self, annotation: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN annotation object to XML
:param annotation: A dictionary representing a BPMN annotation element
Expand All @@ -293,7 +294,7 @@ def __serialize_annotation(self, annotation: dict, connected_flows: list[dict] =

return serialized_annotation

def __serialize_call_activity(self, call_activity: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_call_activity(self, call_activity: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize an BPMN call activity to XML
:param call_activity: A dictionary representing an BPMN call activity element
Expand All @@ -305,7 +306,7 @@ def __serialize_call_activity(self, call_activity: dict, connected_flows: list[d

return serialized_call_activity

def __serialize_data_object(self, data_object: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_data_object(self, data_object: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN data object to XML
:param data_object: A dictionary representing a BPMN data object element
Expand All @@ -316,7 +317,7 @@ def __serialize_data_object(self, data_object: dict, connected_flows: list[dict]

return serialized_data_object

def __serialize_data_store(self, data_store: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_data_store(self, data_store: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN data store object to XML
:param data_store: A dictionary representing a BPMN data store element
Expand All @@ -327,7 +328,7 @@ def __serialize_data_store(self, data_store: dict, connected_flows: list[dict] =

return serialized_data_store

def __serialize_end_event(self, end_event: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_end_event(self, end_event: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN end event object to XML
:param end_event: A dictionary representing a BPMN end event element
Expand All @@ -346,7 +347,7 @@ def __serialize_end_event(self, end_event: dict, connected_flows: list[dict] = N

return serialized_end_event

def __serialize_flow(self, flow: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_flow(self, flow: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN flow to XML
:param flow: A dictionary representing a BPMN flow element
Expand All @@ -363,7 +364,7 @@ def __serialize_flow(self, flow: dict, connected_flows: list[dict] = None) -> El

return serialized_flow

def __serialize_gateway(self, gateway: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_gateway(self, gateway: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN gateway object to XML
:param gateway: A dictionary representing a BPMN gateway element
Expand All @@ -375,7 +376,7 @@ def __serialize_gateway(self, gateway: dict, connected_flows: list[dict] = None)

return serialized_gateway

def __serialize_group(self, group: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_group(self, group: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN group to XML
:param group: A dictionary representing a BPMN group element
Expand All @@ -387,7 +388,7 @@ def __serialize_group(self, group: dict, connected_flows: list[dict] = None) ->
return serialized_group

def __serialize_intermediate_event(self, intermediate_event: dict,
connected_flows: list[dict] = None) -> ElementTree.Element:
connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN intermediate event to XML
:param intermediate_event: A dictionary representing a BPMN intermediate event element
Expand All @@ -407,7 +408,7 @@ def __serialize_intermediate_event(self, intermediate_event: dict,

return serialized_intermediate_event

def __serialize_pool(self, pool: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_pool(self, pool: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN pool to XML
:param pool: A dictionary representing a BPMN pool element
Expand All @@ -418,7 +419,7 @@ def __serialize_pool(self, pool: dict, connected_flows: list[dict] = None) -> El

return serialized_pool

def __serialize_start_event(self, start_event: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_start_event(self, start_event: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN start event to XML
:param start_event: A dictionary representing a BPMN start event element
Expand All @@ -436,7 +437,7 @@ def __serialize_start_event(self, start_event: dict, connected_flows: list[dict]

return serialized_start_event

def __serialize_subprocess(self, subprocess: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_subprocess(self, subprocess: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN subprocess to XML
:param subprocess: A dictionary representing a BPMN subprocess element
Expand All @@ -447,7 +448,7 @@ def __serialize_subprocess(self, subprocess: dict, connected_flows: list[dict] =

return serialized_subprocess

def __serialize_swimlane(self, swimlane: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_swimlane(self, swimlane: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN swimlane to XML
:param swimlane: A dictionary representing a BPMN swimlane element
Expand All @@ -458,7 +459,7 @@ def __serialize_swimlane(self, swimlane: dict, connected_flows: list[dict] = Non

return serialized_swimlane

def __serialize_task(self, task: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_task(self, task: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN task to XML
:param task: A dictionary representing a BPMN task element
Expand All @@ -469,7 +470,7 @@ def __serialize_task(self, task: dict, connected_flows: list[dict] = None) -> El

return serialized_task

def __serialize_transaction(self, transaction: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_transaction(self, transaction: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN transaction to XML
:param transaction: A dictionary representing a BPMN transaction element
Expand All @@ -480,7 +481,7 @@ def __serialize_transaction(self, transaction: dict, connected_flows: list[dict]

return serialized_transaction

def __serialize_element(self, element: dict, connected_flows: list[dict] = None) -> ElementTree.Element:
def __serialize_element(self, element: dict, connected_flows: Optional[list[dict]] = None) -> ElementTree.Element:
"""
Serialize a BPMN element to XML
Expand Down

0 comments on commit bd5b1c1

Please sign in to comment.