diff --git a/src/dvsim/job/deploy.py b/src/dvsim/job/deploy.py index 71247b85..54cf84a5 100644 --- a/src/dvsim/job/deploy.py +++ b/src/dvsim/job/deploy.py @@ -98,8 +98,16 @@ def __init__(self, sim_cfg: "SimCfg") -> None: # Do variable substitutions. self._subst_vars() - # List of vars required to be exported to sub-shell, as a dict. - self.exports = self._process_exports() + # List of vars required to be exported to sub-shell, as a dict. This + # has been loaded from the hjson as a list of dicts and we want to + # flatten it to a single dictionary. + # + # The slightly odd dance with the variables is to convince Pyright + # about the types we end up with. + exports_list: object = self.exports + if not isinstance(exports_list, list): + raise TypeError("Loaded exports value should be a list of dicts.") + self.exports: dict[str, str] = self._process_exports(exports_list) # Construct the job's command. self.cmd = self._construct_cmd() @@ -276,7 +284,7 @@ def _subst_vars(self, ignored_subst_vars=None) -> None: ignore_error=False, ) - def _process_exports(self) -> Mapping: + def _process_exports(self, exports_list: list[dict[str, str]]) -> dict[str, str]: """Convert 'exports' as a list of dicts in the HJson to a dict. Exports is a list of key-value pairs that are to be exported to the @@ -286,7 +294,7 @@ def _process_exports(self) -> Mapping: into a dict variable, which makes it easy to merge the list of exports with the subprocess' env where the ASIC tool is invoked. """ - return {k: str(v) for item in self.exports for k, v in item.items()} + return {k: str(v) for item in exports_list for k, v in item.items()} def _construct_cmd(self) -> str: """Construct the command that will eventually be launched."""