def _assign_params(
            ctx: Context,
            params_assigned_from_default: set,
            params_assigned_from_user: set,
            deprecated_env_vars: Dict[str, Callable],
        ):
            """Recursively adds all click params to flag object"""
            for param_name, param_value in ctx.params.items():
                # N.B. You have to use the base MRO method (object.__setattr__) to set attributes
                # when using frozen dataclasses.
                # https://docs.python.org/3/library/dataclasses.html#frozen-instances

                # Handle deprecated env vars while still respecting old values
                # e.g. DBT_NO_PRINT -> DBT_PRINT if DBT_NO_PRINT is set, it is
                # respected over DBT_PRINT or --print.
                new_name: Union[str, None] = None
                if param_name in DEPRECATED_PARAMS:
                    # Deprecated env vars can only be set via env var.
                    # We use the deprecated option in click to serialize the value
                    # from the env var string.
                    param_source = ctx.get_parameter_source(param_name)
                    if param_source == ParameterSource.DEFAULT:
                        continue
                    elif param_source != ParameterSource.ENVIRONMENT:
                        raise DbtUsageException(
                            "Deprecated parameters can only be set via environment variables",
                        )

                    # Rename for clarity.
                    dep_name = param_name
                    new_name = DEPRECATED_PARAMS.get(dep_name)
                    try:
                        assert isinstance(new_name, str)
                    except AssertionError:
                        raise Exception(
                            f"No deprecated param name match in DEPRECATED_PARAMS from {dep_name} to {new_name}"
                        )

                    # Find param objects for their envvar name.
                    try:
                        dep_param = [x for x in ctx.command.params if x.name == dep_name][0]
                        new_param = [x for x in ctx.command.params if x.name == new_name][0]
                    except IndexError:
                        raise Exception(
                            f"No deprecated param name match in context from {dep_name} to {new_name}"
                        )

                    # Remove param from defaulted set since the deprecated
                    # value is not set from default, but from an env var.
                    if new_name in params_assigned_from_default:
                        params_assigned_from_default.remove(new_name)

                    # Add the deprecation warning function to the set.
                    assert isinstance(dep_param.envvar, str)
                    assert isinstance(new_param.envvar, str)
                    deprecated_env_vars[new_name] = renamed_env_var(
                        old_name=dep_param.envvar,
                        new_name=new_param.envvar,
                    )
                # end deprecated_params

                # Set the flag value.
                is_duplicate = (
                    hasattr(self, param_name.upper())
                    and param_name.upper() not in flags_defaults_list
                )
                # First time through, set as though FLAGS_DEFAULTS hasn't been set, so not a duplicate.
                # Subsequent pass (to process "parent" params) should be treated as duplicates.
                if param_name.upper() in flags_defaults_list:
                    flags_defaults_list.remove(param_name.upper())
                # Note: the following determines whether parameter came from click default,
                # not from FLAGS_DEFAULTS in __init__.
                is_default = ctx.get_parameter_source(param_name) == ParameterSource.DEFAULT
                is_envvar = ctx.get_parameter_source(param_name) == ParameterSource.ENVIRONMENT

                flag_name = (new_name or param_name).upper()

                # envvar flags are assigned in either parent or child context if there
                # isn't an overriding cli command flag.
                # If the flag has been encountered as a child cli flag, we don't
                # want to overwrite with parent envvar, since the commandline flag takes precedence.
                if (is_duplicate and not (is_default or is_envvar)) or not is_duplicate:
                    object.__setattr__(self, flag_name, param_value)

                # Track default assigned params.
                # For flags that are accepted at both 'parent' and 'child' levels,
                # we need to track user-provided and default values across both,
                # to support detection of mutually exclusive flags later on.
                if not is_default:
                    params_assigned_from_user.add(param_name)
                    if param_name in params_assigned_from_default:
                        params_assigned_from_default.remove(param_name)
                if is_default and param_name not in params_assigned_from_user:
                    params_assigned_from_default.add(param_name)

            if ctx.parent:
                _assign_params(
                    ctx.parent,
                    params_assigned_from_default,
                    params_assigned_from_user,
                    deprecated_env_vars,
                )
Recursively adds all click params to flag object
core/dbt/cli/flags.py