From 99ef61afadf4b13bee2c2cc55f2335073cd6a55c Mon Sep 17 00:00:00 2001 From: Anderson Bravalheri Date: Thu, 2 May 2024 11:59:31 +0100 Subject: [PATCH] Fix warnings in sphinx docs --- docs/conf.py | 4 ++++ importlib_metadata/__init__.py | 25 ++++++------------------- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 90a1da2a..0226a0c2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -71,4 +71,8 @@ ('py:class', '_T'), # Other workarounds ('py:class', 'importlib_metadata.DeprecatedNonAbstract'), + # importlib.metadata in stdlib does not have detailed API docs + ('py:class', 'importlib.metadata.Distribution'), + ('py:class', 'importlib.metadata.PackagePath'), + ('py:class', 'importlib.metadata._meta.PackageMetadata'), ] diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 25fff2a2..61f587de 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -31,28 +31,15 @@ from contextlib import suppress from importlib import import_module +from importlib import metadata as _legacy from importlib.abc import MetaPathFinder from itertools import starmap -from typing import ( - TYPE_CHECKING, - Any, - Iterable, - List, - Mapping, - Match, - Optional, - Set, - cast, -) - - -if TYPE_CHECKING: - from importlib import metadata as _legacy +from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast - if sys.version_info >= (3, 10): - from importlib.metadata import PackageMetadata as _legacy_Metadata - else: - from email.message import Message as _legacy_Metadata +if sys.version_info >= (3, 10): + from importlib.metadata import PackageMetadata as _legacy_Metadata +else: + from email.message import Message as _legacy_Metadata __all__ = [