File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55from _warnings import warn
66from ast import literal_eval
77from contextlib import contextmanager
8+ from enum import Enum
89from functools import wraps
910from importlib import metadata
1011from os import PathLike , chdir , environ
1112from pathlib import Path , PurePosixPath
1213from shutil import which
1314from subprocess import run
1415from timeit import timeit
16+ from typing import Any
1517from urllib import request
1618from urllib .error import URLError
1719
@@ -550,3 +552,11 @@ def set_env(*remove, **update):
550552 finally :
551553 env .update (update_after )
552554 [env .pop (k ) for k in remove_after ]
555+
556+
557+ def try_get_enum_value (v : Any ) -> Any :
558+ """
559+ Get the enum's value if the object is an instance
560+ of an enumeration, otherwise return it unaltered.
561+ """
562+ return v .value if isinstance (v , Enum ) else v
You can’t perform that action at this time.
0 commit comments