def filter_not_modifiable_env_vars()

in composer_local_dev/environment.py [0:0]


def filter_not_modifiable_env_vars(env_vars: Dict) -> Dict:
    """
    Filter out environment variables that cannot be modified by user.
    """
    filtered_env_vars = dict()
    for key, val in env_vars.items():
        if key in constants.NOT_MODIFIABLE_ENVIRONMENT_VARIABLES:
            LOG.warning(
                "'%s' environment variable cannot be set and will be ignored.",
                key,
            )
        elif key in constants.STRICT_ENVIRONMENT_VARIABLES:
            possible_values = constants.STRICT_ENVIRONMENT_VARIABLES[key]
            if val not in possible_values:
                LOG.warning(
                    "'%s' environment variable can be set "
                    "to the one of the following values: '%s'",
                    key,
                    ",".join(possible_values),
                )
            else:
                env_vars[key] = val
        else:
            filtered_env_vars[key] = val
    return filtered_env_vars