Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_importlib_metadata.py56 linesDownload Raw Back to util
1# Copyright The OpenTelemetry Authors2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7#     http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14 15from functools import cache16 17# FIXME: Use importlib.metadata (not importlib_metadata)18# when support for 3.11 is dropped if the rest of19# the supported versions at that time have the same API.20from importlib_metadata import (  # type: ignore21    Distribution,22    EntryPoint,23    EntryPoints,24    PackageNotFoundError,25    distributions,26    requires,27    version,28)29from importlib_metadata import (30    entry_points as original_entry_points,31)32 33 34@cache35def _original_entry_points_cached():36    return original_entry_points()37 38 39def entry_points(**params) -> EntryPoints:40    """Replacement for importlib_metadata.entry_points that caches getting all the entry points.41 42    That part can be very slow, and OTel uses this function many times."""43    return _original_entry_points_cached().select(**params)44 45 46__all__ = [47    "entry_points",48    "version",49    "EntryPoint",50    "EntryPoints",51    "requires",52    "Distribution",53    "distributions",54    "PackageNotFoundError",55]56 
codekingpro/portable-devtools · Team Ai