Skip to content
Snippets Groups Projects
Commit 433160cf authored by I. Nüske's avatar I. Nüske
Browse files

MNT: Replace dict default values with None and update in method body

parent 40961b1d
Branches
Tags
2 merge requests!128MNT: Added a warning when column metadata is not configured, and a better...,!126Fix pylint errors
......@@ -66,7 +66,7 @@ def separated(text):
return "-"*60 + "\n" + text
def apply_list_of_updates(to_be_updated, update_flags={},
def apply_list_of_updates(to_be_updated, update_flags=None,
update_cache=None, run_id=None):
"""Updates the `to_be_updated` Container, i.e., pushes the changes to LinkAhead
after removing possible duplicates. If a chace is provided, uauthorized
......@@ -86,6 +86,8 @@ def apply_list_of_updates(to_be_updated, update_flags={},
Id with which the pending updates are cached. Only meaningful if
`update_cache` is provided. Default is None.
"""
if update_flags is None:
update_flags = {}
if len(to_be_updated) == 0:
return
......
......@@ -162,7 +162,7 @@ debug : bool, optional
def parse_model_from_json_schema(
filename: str,
top_level_recordtype: bool = True,
types_for_missing_array_items: dict = {},
types_for_missing_array_items: dict = None,
ignore_unspecified_array_items: bool = False,
existing_model: Optional[dict] = None
):
......@@ -204,6 +204,9 @@ def parse_model_from_json_schema(
about the limitations of the current implementation.
"""
if types_for_missing_array_items is None:
types_for_missing_array_items = {}
if existing_model is not None:
raise NotImplementedError("Adding to an existing model is not implemented yet.")
......@@ -706,8 +709,11 @@ class JsonSchemaParser(Parser):
# @date 2022-02-17
# @review Timm Fitschen 2023-05-25
def __init__(self, types_for_missing_array_items={}, ignore_unspecified_array_items=False):
def __init__(self, types_for_missing_array_items=None,
ignore_unspecified_array_items=False):
super().__init__()
if types_for_missing_array_items is None:
types_for_missing_array_items = {}
self.types_for_missing_array_items = types_for_missing_array_items
self.ignore_unspecified_array_items = ignore_unspecified_array_items
......
......@@ -110,8 +110,7 @@ def date_converter(val, fmt="%Y-%m-%d"):
return datetime_converter(val, fmt=fmt).date()
def incomplete_date_converter(val, fmts={"%Y-%m-%d": "%Y-%m-%d",
"%Y-%m": "%Y-%m", "%Y": "%Y"}):
def incomplete_date_converter(val, fmts=None):
""" if the value is already a datetime, it is returned otherwise it
converts it using format string
......@@ -124,6 +123,8 @@ def incomplete_date_converter(val, fmts={"%Y-%m-%d": "%Y-%m-%d",
keys are the formats into which the input value is tried to be
converted, values are the possible input formats.
"""
if fmts is None:
fmts = {"%Y-%m-%d": "%Y-%m-%d", "%Y-%m": "%Y-%m", "%Y": "%Y"}
for to, fro in fmts.items():
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment