8000 GH-109653: Defer import of ``importlib.metadata._adapters`` by AA-Turner · Pull Request #109829 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
8000

GH-109653: Defer import of importlib.metadata._adapters #109829

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
adapters
  • Loading branch information
AA-Turner committed Sep 25, 2023
commit 5d01d0cd9e39212e082640e53d3ef55a64a49b27
4 changes: 3 additions & 1 deletion Lib/importlib/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import collections
import inspect

from . import _adapters, _meta
from . import _meta
from ._collections import FreezableDefaultDict, Pair
from ._functools import method_cache, pass_none
from ._itertools import always_iterable, unique_everseen
Expand Down Expand Up @@ -439,6 +439,8 @@ def metadata(self) -> _meta.PackageMetadata:
The returned object will have keys that name the various bits of
metadata. See PEP 566 for details.
"""
from . import _adapters

opt_text = (
self.read_text('METADATA')
or self.read_text('PKG-INFO')
Expand Down
3 changes: 1 addition & 2 deletions Lib/importlib/resources/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from typing import Union, Optional, cast
from .abc import ResourceReader, Traversable

from ._adapters import wrap_spec

Package = Union[types.ModuleType, str]
Anchor = Package

Expand Down Expand Up @@ -109,6 +107,7 @@ def from_package(package: types.ModuleType):
Return a Traversable object for the given package.

"""
from ._adapters import wrap_spec
spec = wrap_spec(package)
reader = spec.loader.get_resource_reader(spec.name)
return reader.files()
Expand Down
0