def _get_env_var(parser, action) -> str:
    """Returns the environment variable for a given parser and action."""
    if hasattr(parser, '_parser'):
        parser = parser._parser
    env_var = (parser._env_prefix+'_' if parser._env_prefix else '') + action.dest
    env_var = env_var.replace('.', '__').upper()
    return env_var