|
24 | 24 | import logging
|
25 | 25 | import re
|
26 | 26 | from datetime import datetime
|
27 |
| -from typing import (TYPE_CHECKING, Any, Iterable, Mapping, Sequence, TypeVar, cast) |
| 27 | +from typing import TYPE_CHECKING, Any, Iterable, Mapping, TypeVar, cast |
28 | 28 |
|
29 | 29 | import deepdiff # type: ignore[import] # Due to missing typing stubs for deepdiff
|
30 |
| -import deepdiff.model # type: ignore[import] # Due to missing typing stubs for deepdiff |
| 30 | +import deepdiff.model # type: ignore[import] # Due to missing typing stubs for deepdiff |
31 | 31 | import jsonschema
|
32 | 32 |
|
33 | 33 | import objdictgen
|
34 | 34 | # Accessed by node.py, so we need to import node as module to avoid circular references
|
35 | 35 | from objdictgen import maps
|
36 | 36 | from objdictgen import node as nodelib
|
37 | 37 | from objdictgen.maps import OD, ODMapping, ODMappingList
|
38 |
| -from objdictgen.typing import (TDiffNodes, TIndexEntry, TODJson, TODObjJson, |
39 |
| - TODObj, TODSubObj, TODSubObjJson, TODValue, TParamEntry, TPath, TProfileMenu) |
| 38 | +from objdictgen.typing import (TDiffNodes, TIndexEntry, TODJson, TODObj, |
| 39 | + TODObjJson, TODSubObj, TODSubObjJson, TODValue, |
| 40 | + TParamEntry, TPath, TProfileMenu) |
40 | 41 | from objdictgen.utils import (copy_in_order, exc_amend, maybe_number,
|
41 | 42 | str_to_int, strip_brackets)
|
42 | 43 |
|
@@ -255,7 +256,7 @@ def member_compare(
|
255 | 256 |
|
256 | 257 |
|
257 | 258 | def get_object_types(
|
258 |
| - node: "Node|None" = None, |
| 259 | + node: Node|None = None, |
259 | 260 | dictionary: list[TODObjJson]|None = None
|
260 | 261 | ) -> tuple[dict[int, str], dict[str, int]]:
|
261 | 262 | """ Return two dicts with the object type mapping """
|
@@ -320,7 +321,7 @@ def compare_profile(profilename: TPath, params: ODMapping, menu: TProfileMenu|No
|
320 | 321 | return False, False
|
321 | 322 |
|
322 | 323 |
|
323 |
| -def generate_jsonc(node: "Node", compact=False, sort=False, internal=False, |
| 324 | +def generate_jsonc(node: Node, compact=False, sort=False, internal=False, |
324 | 325 | validate=True, jsonc=True) -> str:
|
325 | 326 | """ Export a JSONC string representation of the node """
|
326 | 327 |
|
@@ -372,7 +373,7 @@ def generate_jsonc(node: "Node", compact=False, sort=False, internal=False,
|
372 | 373 | return text
|
373 | 374 |
|
374 | 375 |
|
375 |
| -def generate_node(contents: str|TODJson, validate: bool = True) -> "Node": |
| 376 | +def generate_node(contents: str|TODJson, validate: bool = True) -> Node: |
376 | 377 | """ Import from JSON string or objects """
|
377 | 378 |
|
378 | 379 | if isinstance(contents, str):
|
@@ -413,7 +414,7 @@ def generate_node(contents: str|TODJson, validate: bool = True) -> "Node":
|
413 | 414 | return node_fromdict(jd, objtypes_s2i)
|
414 | 415 |
|
415 | 416 |
|
416 |
| -def node_todict(node: "Node", sort=False, rich=True, internal=False, validate=True) -> TODJson: |
| 417 | +def node_todict(node: Node, sort=False, rich=True, internal=False, validate=True) -> TODJson: |
417 | 418 | """
|
418 | 419 | Convert a node to dict representation for serialization.
|
419 | 420 |
|
@@ -666,7 +667,7 @@ def indexentry_to_jsondict(ientry: TIndexEntry) -> TODObjJson:
|
666 | 667 | return obj
|
667 | 668 |
|
668 | 669 |
|
669 |
| -def rearrage_for_json(obj: TODObjJson, node: "Node", objtypes_i2s: dict[int, str], rich=True) -> TODObjJson: |
| 670 | +def rearrage_for_json(obj: TODObjJson, node: Node, objtypes_i2s: dict[int, str], rich=True) -> TODObjJson: |
670 | 671 | """ Rearrange the object to fit the wanted JSON format """
|
671 | 672 |
|
672 | 673 | # The struct describes what kind of object structure this object have
|
@@ -903,7 +904,7 @@ def validate_indexentry(ientry: TIndexEntry):
|
903 | 904 | raise ValidationError(f"Unexpexted count of subindexes in mapping object, found {len(nbmax)}")
|
904 | 905 |
|
905 | 906 |
|
906 |
| -def node_fromdict(jd: TODJson, objtypes_s2i: dict[str, int]) -> "Node": |
| 907 | +def node_fromdict(jd: TODJson, objtypes_s2i: dict[str, int]) -> Node: |
907 | 908 | """ Convert a dict jd into a Node """
|
908 | 909 |
|
909 | 910 | # Create the node and fill the most basic data
|
|
0 commit comments