Skip to content
Snippets Groups Projects
Commit b0eed6d9 authored by florian's avatar florian
Browse files

FIX: Make type checks compatible to Python3.8

parent c9bd0ced
No related branches found
No related tags found
2 merge requests!53Release 0.1,!25F macros
Pipeline #28923 passed with warnings
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# A. Schlemmer, 05/2022 # A. Schlemmer, 05/2022
from dataclasses import dataclass from dataclasses import dataclass
from typing import Any from typing import Any, Dict
from copy import deepcopy from copy import deepcopy
from string import Template from string import Template
...@@ -40,12 +40,12 @@ class MacroDefinition: ...@@ -40,12 +40,12 @@ class MacroDefinition:
definition: A dictionary that will be substituted including parameters definition: A dictionary that will be substituted including parameters
""" """
name: str name: str
params: dict[str, Any] params: Dict[str, Any]
definition: Any definition: Any
# This dictionary stores the macro definitions # This dictionary stores the macro definitions
macro_store: dict[str, MacroDefinition] = dict() macro_store: Dict[str, MacroDefinition] = dict()
def substitute(propvalue, values: dict): def substitute(propvalue, values: dict):
...@@ -57,14 +57,14 @@ def substitute(propvalue, values: dict): ...@@ -57,14 +57,14 @@ def substitute(propvalue, values: dict):
return propvalue_template.safe_substitute(**values) return propvalue_template.safe_substitute(**values)
def substitute_dict(sourced: dict[str, Any], values: dict[str, Any]): def substitute_dict(sourced: Dict[str, Any], values: Dict[str, Any]):
""" """
Create a copy of sourced. Create a copy of sourced.
Afterwards recursively do variable substitution on all keys and values. Afterwards recursively do variable substitution on all keys and values.
""" """
d = deepcopy(sourced) d = deepcopy(sourced)
# Changes in keys: # Changes in keys:
replace: dict[str, str] = dict() replace: Dict[str, str] = dict()
for k in d: for k in d:
replacement = substitute(k, values) replacement = substitute(k, values)
if replacement != k: if replacement != k:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment