Skip to content
Snippets Groups Projects
Commit caceab21 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

MAINT: typing

parent 016c0bb0
No related branches found
No related tags found
4 merge requests!100WIP: Filling XLSX: Seems to be working.,!94ENH: add framework for converting json schema into table templates,!93Filling XLSX: Everything except multiple choice.,!92ENH: xlsx template generator
......@@ -28,7 +28,7 @@ import sys
from abc import ABC, abstractmethod
from argparse import RawTextHelpFormatter
from enum import Enum
from typing import Union
from typing import Dict, List, Tuple, Union
from openpyxl import Workbook
from openpyxl.workbook.child import INVALID_TITLE_REGEX
......@@ -74,7 +74,7 @@ class TableTemplateGenerator(ABC):
pass
def _generate_sheets_from_schema(self, schema: dict, foreign_keys: dict = None
) -> dict[str, dict[str, list]]:
) -> Dict[str, Dict[str, list]]:
""" generates a sheet definition from a given JSON schema
Parameters
......@@ -104,7 +104,7 @@ class TableTemplateGenerator(ABC):
foreign_keys = {}
# here, we treat the top level
# sheets[sheetname][colname]= (COL_TYPE, description, [path])
sheets: dict[str, dict[str, tuple[str, list]]] = {}
sheets: Dict[str, dict[str, Tuple[str, list]]] = {}
if "properties" not in schema:
raise ValueError("Inappropriate JSON schema: The following part should contain "
f"the 'properties' key:\n{schema}\n")
......@@ -141,7 +141,7 @@ class TableTemplateGenerator(ABC):
def _treat_schema_element(self, schema: dict, sheets: dict = None, path: list = None,
foreign_keys: dict = None, level_in_sheet_name: int = 1,
array_paths: list = None
) -> dict[str, tuple[str, str, list]]:
) -> Dict[str, Tuple[str, str, list]]:
""" recursively transforms elements from the schema into column definitions
sheets is modified in place.
......
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