Skip to content

Commit

Permalink
Inline StrOrIo
Browse files Browse the repository at this point in the history
Solves `reportInvalidTypeForm: Variable not allowed in type expression`
  • Loading branch information
VaeterchenFrost committed Dec 20, 2024
1 parent b4932e2 commit f7504ab
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tdvisu/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,8 @@

LOGGER = logging.getLogger("visualization.py")

StrOrIo = NewType("StrOrIo", Union[str, io.TextIOWrapper])


def read_json(json_data: StrOrIo) -> dict:
def read_json(json_data: Union[str, io.TextIOWrapper]) -> dict:
"""
Read json data into a callable object.
Throws AssertionError if the parsed object has length 0.
Expand Down Expand Up @@ -95,14 +93,14 @@ class Visualization:
of dynamic programming on tree decomposition.
"""

def __init__(self, infile: StrOrIo, outfolder: Path):
def __init__(self, infile: Union[str, io.TextIOWrapper], outfolder: Path):
"""Copy needed fields from arguments and create VisualizationData."""
self.data: VisualizationData = self.inspect_json(infile)
self.outfolder = Path(outfolder).resolve()
self.tree_dec_digraph = None
LOGGER.debug("Initialized: %s", self)

def inspect_json(self, infile: StrOrIo) -> VisualizationData:
def inspect_json(self, infile: Union[str, io.TextIOWrapper]) -> VisualizationData:
"""Read and preprocess the needed data from the infile into VisualizationData."""
LOGGER.debug("Reading from: %s", infile)
visudata = read_json(infile)
Expand Down

0 comments on commit f7504ab

Please sign in to comment.