Skip to content
Snippets Groups Projects
Commit f4d219de authored by Alexander Schlemmer's avatar Alexander Schlemmer
Browse files

MAINT: made type hints backwards compatible

parent 2cf581f7
No related branches found
No related tags found
No related merge requests found
Pipeline #24791 failed
...@@ -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, List, Dict
from copy import deepcopy from copy import deepcopy
from string import Template from string import Template
...@@ -39,11 +39,11 @@ class MacroDefinition: ...@@ -39,11 +39,11 @@ 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):
...@@ -55,14 +55,14 @@ def substitute(propvalue, values: dict): ...@@ -55,14 +55,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