mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-19 10:21:14 +08:00
Resolve importlib.metadata 3.13 issues (#12299)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import abc
|
||||
import pathlib
|
||||
import sys
|
||||
import types
|
||||
from _collections_abc import dict_keys, dict_values
|
||||
from _typeshed import StrPath
|
||||
from collections.abc import Iterable, Iterator, Mapping
|
||||
@@ -36,11 +37,8 @@ if sys.version_info >= (3, 10):
|
||||
from importlib.metadata._meta import PackageMetadata as PackageMetadata, SimplePath
|
||||
def packages_distributions() -> Mapping[str, list[str]]: ...
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
# It's generic but shouldn't be
|
||||
_SimplePath: TypeAlias = SimplePath[Any]
|
||||
else:
|
||||
_SimplePath: TypeAlias = SimplePath
|
||||
_SimplePath: TypeAlias = SimplePath
|
||||
|
||||
else:
|
||||
_SimplePath: TypeAlias = Path
|
||||
|
||||
@@ -48,7 +46,9 @@ class PackageNotFoundError(ModuleNotFoundError):
|
||||
@property
|
||||
def name(self) -> str: ... # type: ignore[override]
|
||||
|
||||
if sys.version_info >= (3, 11):
|
||||
if sys.version_info >= (3, 13):
|
||||
_EntryPointBase = object
|
||||
elif sys.version_info >= (3, 11):
|
||||
class DeprecatedTuple:
|
||||
def __getitem__(self, item: int) -> str: ...
|
||||
|
||||
@@ -226,6 +226,9 @@ class Distribution(_distribution_parent):
|
||||
if sys.version_info >= (3, 10):
|
||||
@property
|
||||
def name(self) -> str: ...
|
||||
if sys.version_info >= (3, 13):
|
||||
@property
|
||||
def origin(self) -> types.SimpleNamespace: ...
|
||||
|
||||
class DistributionFinder(MetaPathFinder):
|
||||
class Context:
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import sys
|
||||
from _typeshed import StrPath
|
||||
from collections.abc import Iterator
|
||||
from typing import Any, Protocol, TypeVar, overload
|
||||
from os import PathLike
|
||||
from typing import Any, Protocol, overload
|
||||
from typing_extensions import TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
_T_co = TypeVar("_T_co", covariant=True, default=Any)
|
||||
|
||||
class PackageMetadata(Protocol):
|
||||
def __len__(self) -> int: ...
|
||||
@@ -22,7 +25,18 @@ class PackageMetadata(Protocol):
|
||||
@overload
|
||||
def get(self, name: str, failobj: _T) -> _T | str: ...
|
||||
|
||||
if sys.version_info >= (3, 12):
|
||||
if sys.version_info >= (3, 13):
|
||||
class SimplePath(Protocol):
|
||||
def joinpath(self, other: StrPath, /) -> SimplePath: ...
|
||||
def __truediv__(self, other: StrPath, /) -> SimplePath: ...
|
||||
# Incorrect at runtime
|
||||
@property
|
||||
def parent(self) -> PathLike[str]: ...
|
||||
def read_text(self, encoding: str | None = None) -> str: ...
|
||||
def read_bytes(self) -> bytes: ...
|
||||
def exists(self) -> bool: ...
|
||||
|
||||
elif sys.version_info >= (3, 12):
|
||||
class SimplePath(Protocol[_T_co]):
|
||||
# At runtime this is defined as taking `str | _T`, but that causes trouble.
|
||||
# See #11436.
|
||||
|
||||
2
stdlib/importlib/metadata/diagnose.pyi
Normal file
2
stdlib/importlib/metadata/diagnose.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
def inspect(path: str) -> None: ...
|
||||
def run() -> None: ...
|
||||
Reference in New Issue
Block a user