From 3d86cdb2b98630f8ab58367aa286160d2d1f0503 Mon Sep 17 00:00:00 2001 From: Justin Bandoro <79104794+jbandoro@users.noreply.github.com> Date: Wed, 13 Dec 2023 04:00:47 -0800 Subject: [PATCH] Fix type check error in `DbtKubernetesBaseOperator.build_env_args` (#766) The imported function `airflow.providers.cncf.kubernetes.backcompat.backwards_compat_converters.convert_env_vars` was recently updated with type hints and can only accept dictionaries of type `dict[str, str]`. The fix in this PR is to ensure the env var values are strings. Closes #765 --- cosmos/operators/kubernetes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cosmos/operators/kubernetes.py b/cosmos/operators/kubernetes.py index af0988a6a..b844716de 100644 --- a/cosmos/operators/kubernetes.py +++ b/cosmos/operators/kubernetes.py @@ -56,10 +56,12 @@ def __init__(self, profile_config: ProfileConfig | None = None, **kwargs: Any) - def build_env_args(self, env: dict[str, str | bytes | PathLike[Any]]) -> None: env_vars_dict: dict[str, str] = dict() + for env_var_key, env_var_value in env.items(): + env_vars_dict[env_var_key] = str(env_var_value) for env_var in self.env_vars: env_vars_dict[env_var.name] = env_var.value - self.env_vars: list[Any] = convert_env_vars({**env, **env_vars_dict}) + self.env_vars: list[Any] = convert_env_vars(env_vars_dict) def build_and_run_cmd(self, context: Context, cmd_flags: list[str] | None = None) -> Any: self.build_kube_args(context, cmd_flags)