1import contextlib 2import sys 3 4 5if sys.version_info >= (3, 10): 6 import importlib.metadata as metadata 7else: 8 import setuptools.extern.importlib_metadata as metadata # type: ignore # noqa: F401 9 10 11def repair_extras(extras): 12 """ 13 Repair extras that appear as match objects. 14 15 python/importlib_metadata#369 revealed a flaw in the EntryPoint 16 implementation. This function wraps the extras to ensure 17 they are proper strings even on older implementations. 18 """ 19 with contextlib.suppress(AttributeError): 20 return list(item.group(0) for item in extras) 21 return extras 22