diff --git a/src/caosadvancedtools/json_schema_exporter.py b/src/caosadvancedtools/json_schema_exporter.py index bce3102eef423a84206eb4596352d49dd4d8ff9f..fcccd2981b37499cc45203be070abb09c9562176 100644 --- a/src/caosadvancedtools/json_schema_exporter.py +++ b/src/caosadvancedtools/json_schema_exporter.py @@ -124,8 +124,8 @@ class JsonSchemaExporter: that the exporter may fail if this option is activated and the data model is not self-sufficient. use_rt_pool : models.data_model.DataModel, optional - If given, do not attempt to retrieve RecordType information remotely but from this parameter - instead. + If given, do not attempt to retrieve RecordType information remotely but from this + parameter instead. multiple_choice : list[str], optional A list of reference Property names which shall be denoted as multiple choice properties. This means that each option in this property may be selected at most once. This is not @@ -341,7 +341,8 @@ ui_schema : dict rt = db.Entity() if isinstance(rt, str): - raise NotImplementedError("Behavior is not implemented when _no_remote == True and datatype is given as a string.") + raise NotImplementedError("Behavior is not implemented when _no_remote == " + "True and datatype is given as a string.") subschema, ui_schema = self._make_segment_from_recordtype(rt) if prop.is_reference(): diff --git a/src/caosadvancedtools/table_json_conversion/export_import_xlsx.py b/src/caosadvancedtools/table_json_conversion/export_import_xlsx.py index 99097b4acf70035ed9ad86d501cf1431675ea179..638b2c32d94472a4ef392d373ef718b3c65e369e 100644 --- a/src/caosadvancedtools/table_json_conversion/export_import_xlsx.py +++ b/src/caosadvancedtools/table_json_conversion/export_import_xlsx.py @@ -25,7 +25,7 @@ import json import tempfile import warnings import logging -from typing import Union +from typing import Optional, Union from pathlib import Path import linkahead @@ -44,7 +44,7 @@ logging.disable(logging.NOTSET) def _generate_jsonschema_from_recordtypes(recordtypes: list, - out_path: Union[str, Path] = None) -> dict: + out_path: Optional[Union[str, Path]] = None) -> dict: """ Generate a combined jsonschema for all given recordtypes. @@ -52,7 +52,7 @@ def _generate_jsonschema_from_recordtypes(recordtypes: list, ---------- recordtypes : Iterable List of RecordType entities for which a schema should be generated. - out_path : str, Path + out_path : str or Path, optional If given, the resulting jsonschema will also be written to the file given by out_path. Optional, default None @@ -78,7 +78,7 @@ def _generate_jsonschema_from_recordtypes(recordtypes: list, def _generate_jsondata_from_records(records: Container, - out_path: Union[str, Path] = None) -> dict: + out_path: Optional[Union[str, Path]] = None) -> dict: """ Extract relevant information (id, name, properties, etc.) from the given records and converts this information to json. @@ -87,7 +87,7 @@ def _generate_jsondata_from_records(records: Container, ---------- records : Iterable List of Record entities from which the data will be converted to json. - out_path : str, Path + out_path : str or Path, optional If given, the resulting jsondata will also be written to the file given by out_path. Optional, default None diff --git a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py index e6268fd63e4b436ec8ae86d35b865e3d7faa9b03..b92adc10a5b654636e2d7ddad4d729458cce7f3a 100644 --- a/src/caosadvancedtools/table_json_conversion/fill_xlsx.py +++ b/src/caosadvancedtools/table_json_conversion/fill_xlsx.py @@ -331,7 +331,7 @@ to_insert: Optional[dict[str, str]] def fill_template(data: Union[dict, str, TextIO], template: str, result: str, - validation_schema: Union[dict, str, TextIO] = None) -> None: + validation_schema: Optional[Union[dict, str, TextIO]] = None) -> None: """Insert json data into an xlsx file, according to a template. This function fills the json data into the template stored at ``template`` and stores the result as @@ -355,6 +355,9 @@ validation_schema: dict, optional # Validation if validation_schema is not None: + validation_schema = read_or_dict(validation_schema) + assert isinstance(validation_schema, dict) + # convert to array_schema if given schema is a model_schema if 'properties' in validation_schema and validation_schema['properties'].values(): if list(validation_schema['properties'].values())[0]["type"] != "array":