Skip to content

Commit

Permalink
typing
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora-Olivia-Ammann committed Apr 26, 2024
1 parent 26e29a4 commit 254283c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/dsp_tools/commands/excel2json/models/input_error.py
Expand Up @@ -260,16 +260,16 @@ def execute_error_protocol(self) -> str:
class ListSheetProblem:
sheet_name: str
root_problems: dict[str, str]
nodes: list[ListNodeProblem] = field(default_factory=list)
node_problems: list[ListNodeProblem] = field(default_factory=list)

def execute_error_protocol(self) -> str:
msg = [
f"The excel sheet '{self.sheet_name}' has the following problem(s):",
]
if self.root_problems:
msg.extend([f"Field: '{key}', Problem: {value}" for key, value in self.root_problems.items()])
if self.nodes:
msg.extend([problem.execute_error_protocol() for problem in self.nodes])
if self.node_problems:
msg.extend([problem.execute_error_protocol() for problem in self.node_problems])
return separator.join(msg)


Expand Down
6 changes: 4 additions & 2 deletions src/dsp_tools/commands/excel2json/new_lists.py
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import Any
from typing import cast

import pandas as pd
import regex
Expand Down Expand Up @@ -67,9 +68,10 @@ def _make_one_list(df: pd.DataFrame, sheet_name: str) -> ListRoot | ListSheetPro
)
match (root, node_problems):
case (ListRoot(), list(ListNodeProblem())):
return ListSheetProblem(sheet_name, root_problems={}, nodes=node_problems)
return ListSheetProblem(sheet_name, root_problems={}, node_problems=node_problems)
case (ListSheetProblem(), _):
root.nodes = node_problems
root = cast(ListSheetProblem, root)
root.node_problems = node_problems
return root


Expand Down

0 comments on commit 254283c

Please sign in to comment.