diff --git a/cwl_utils/cwl_v1_0_expression_refactor.py b/cwl_utils/cwl_v1_0_expression_refactor.py index 4a9cc0b2..ae5f6ec4 100755 --- a/cwl_utils/cwl_v1_0_expression_refactor.py +++ b/cwl_utils/cwl_v1_0_expression_refactor.py @@ -670,8 +670,8 @@ def process_workflow_reqs_and_hints( resourceReq: Optional[cwl.ResourceRequirement] = None envVarReq: Optional[cwl.EnvVarRequirement] = None iwdr: Optional[cwl.InitialWorkDirRequirement] = None - if workflow.requirements: - for req in workflow.requirements: + if workflow.requirements is not None: + for req in cast(List[cwl.ProcessRequirement], workflow.requirements): if req and isinstance(req, cwl.EnvVarRequirement): if req.envDef: for index, envDef in enumerate(req.envDef): @@ -696,7 +696,7 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - if not envVarReq: + if envVarReq is None: envVarReq = copy.deepcopy(req) prop_reqs += (cwl.EnvVarRequirement,) newEnvDef = copy.deepcopy(envDef) diff --git a/cwl_utils/cwl_v1_1_expression_refactor.py b/cwl_utils/cwl_v1_1_expression_refactor.py index 608bc1a9..a27ddcdf 100755 --- a/cwl_utils/cwl_v1_1_expression_refactor.py +++ b/cwl_utils/cwl_v1_1_expression_refactor.py @@ -670,8 +670,8 @@ def process_workflow_reqs_and_hints( resourceReq: Optional[cwl.ResourceRequirement] = None envVarReq: Optional[cwl.EnvVarRequirement] = None iwdr: Optional[cwl.InitialWorkDirRequirement] = None - if workflow.requirements: - for req in workflow.requirements: + if workflow.requirements is not None: + for req in cast(List[cwl.ProcessRequirement], workflow.requirements): if req and isinstance(req, cwl.EnvVarRequirement): if req.envDef: for index, envDef in enumerate(req.envDef): @@ -696,7 +696,7 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - if not envVarReq: + if envVarReq is None: envVarReq = copy.deepcopy(req) prop_reqs += (cwl.EnvVarRequirement,) newEnvDef = copy.deepcopy(envDef) diff --git a/cwl_utils/cwl_v1_2_expression_refactor.py b/cwl_utils/cwl_v1_2_expression_refactor.py index 6fc29907..84361c77 100755 --- a/cwl_utils/cwl_v1_2_expression_refactor.py +++ b/cwl_utils/cwl_v1_2_expression_refactor.py @@ -765,8 +765,8 @@ def process_workflow_reqs_and_hints( resourceReq: Optional[cwl.ResourceRequirement] = None envVarReq: Optional[cwl.EnvVarRequirement] = None iwdr: Optional[cwl.InitialWorkDirRequirement] = None - if workflow.requirements: - for req in workflow.requirements: + if workflow.requirements is not None: + for req in cast(List[cwl.ProcessRequirement], workflow.requirements): if req and isinstance(req, cwl.EnvVarRequirement): if req.envDef: for index, envDef in enumerate(req.envDef): @@ -791,7 +791,7 @@ def process_workflow_reqs_and_hints( None, replace_etool, ) - if not envVarReq: + if envVarReq is None: envVarReq = copy.deepcopy(req) prop_reqs += (cwl.EnvVarRequirement,) newEnvDef = copy.deepcopy(envDef)