Skip to content

Commit 50ac822

Browse files
committed
importlib.resources.contents is deprecated
1 parent 9f7ddd9 commit 50ac822

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

stdlib/importlib/resources/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from contextlib import AbstractContextManager
55
from pathlib import Path
66
from types import ModuleType
77
from typing import Any, BinaryIO, Literal, TextIO
8-
from typing_extensions import TypeAlias
8+
from typing_extensions import TypeAlias, deprecated
99

1010
if sys.version_info >= (3, 11):
1111
from importlib.resources.abc import Traversable
@@ -64,6 +64,7 @@ else:
6464
def read_text(package: Package, resource: Resource, encoding: str = "utf-8", errors: str = "strict") -> str: ...
6565
def path(package: Package, resource: Resource) -> AbstractContextManager[Path, Literal[False]]: ...
6666
def is_resource(package: Package, name: str) -> bool: ...
67+
@deprecated("Deprecated since Python 3.11, use `files(anchor).iterdir()`")
6768
def contents(package: Package) -> Iterator[str]: ...
6869

6970
if sys.version_info >= (3, 11):

stdlib/importlib/resources/_functional.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if sys.version_info >= (3, 13):
99
from io import TextIOWrapper
1010
from pathlib import Path
1111
from typing import BinaryIO, Literal, overload
12-
from typing_extensions import Unpack
12+
from typing_extensions import Unpack, deprecated
1313

1414
def open_binary(anchor: Anchor, *path_names: StrPath) -> BinaryIO: ...
1515
@overload
@@ -27,4 +27,5 @@ if sys.version_info >= (3, 13):
2727
def read_text(anchor: Anchor, *path_names: StrPath, encoding: str | None, errors: str | None = "strict") -> str: ...
2828
def path(anchor: Anchor, *path_names: StrPath) -> AbstractContextManager[Path, Literal[False]]: ...
2929
def is_resource(anchor: Anchor, *path_names: StrPath) -> bool: ...
30+
@deprecated("Deprecated since Python 3.11, use `files(anchor).iterdir()`")
3031
def contents(anchor: Anchor, *path_names: StrPath) -> Iterator[str]: ...

0 commit comments

Comments
 (0)