-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move code specific to backport to compat module
- Loading branch information
1 parent
2044db1
commit 4fe96a4
Showing
2 changed files
with
34 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
""" | ||
Compatibility layer with stdlib. | ||
Only needed when distributing via PyPI/3rd-party package. | ||
""" | ||
|
||
import sys | ||
from typing import TYPE_CHECKING, List, Union | ||
|
||
if TYPE_CHECKING: | ||
# Avoid circular imports | ||
|
||
from importlib import metadata as _legacy | ||
|
||
from typing_extensions import TypeAlias | ||
|
||
from .. import Distribution, PackagePath, _meta | ||
|
||
if sys.version_info >= (3, 10): | ||
from importlib.metadata import PackageMetadata as _legacy_Metadata | ||
else: | ||
from email.message import Message as _legacy_Metadata | ||
|
||
_PackageMetadataOrLegacy: TypeAlias = Union[_legacy_Metadata, _meta.PackageMetadata] | ||
_DistributionOrLegacy: TypeAlias = Union[_legacy.Distribution, Distribution] | ||
_List_PackagePathOrLegacy: TypeAlias = Union[ | ||
List[_legacy.PackagePath], List[PackagePath] | ||
] |