-
-
Couldn't load subscription status.
- Fork 1.9k
Update importlib resources for 3.13 #12298
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
Changes from 61 commits
Commits
Show all changes
68 commits
Select commit
Hold shift + click to select a range
43fd437
Update importlib resources for 3.13
max-muoto 90ea2f3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e99fcca
Fix
max-muoto 23e1544
Fix
max-muoto 14d6a76
Overloads
max-muoto ff35a20
Tweak
max-muoto d1230c3
Fix
max-muoto ad24e2a
use unpack
max-muoto 4d1dfca
Add tests
max-muoto 90f1f34
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] bac332e
All nullable
max-muoto ae8bbe0
Tweak
max-muoto cc428aa
Tweak
max-muoto 55e1c52
Fix
max-muoto f262d0a
Move to _common
max-muoto f91ed1e
Use TS
max-muoto 5d9a9b4
Address comment
max-muoto f4cb586
Fix
max-muoto ad92305
tweak again
max-muoto c44c71b
reorder
max-muoto 9c31008
Tweak
max-muoto bafcf51
Resolve issues
max-muoto f271829
Move to functional
max-muoto 201ba16
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7d46617
Fix
max-muoto 52dfac2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0af767d
tweak
max-muoto af74ee9
Tweak
max-muoto d23df97
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8e516d6
Tweak
max-muoto 49828af
Update stdlib/importlib/resources/__init__.pyi
max-muoto d34c137
Update stdlib/importlib/resources/_functional.pyi
max-muoto c4dc73f
Add
max-muoto 36a5efc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a9dcfc6
Tweak
max-muoto 34d62eb
Tweak
max-muoto e9e7737
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4f999f8
Fix
max-muoto 00ff92b
Tweaks
max-muoto 1880aa1
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8837644
Pos isn't required
max-muoto 56b8e78
Tweak
max-muoto 1b35fd3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] b2c58a1
Use collections.abc.Callable
max-muoto 38ca047
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e0f7095
Merge branch 'main' into importlib.resources
max-muoto 455d5ad
Add ignore
max-muoto a764ad0
Add appropiate ignores
max-muoto 1c74e63
Fix
max-muoto 87c1e55
Fix
max-muoto 6786f6c
Add ignore
max-muoto bced879
Account for older versions
max-muoto e59c349
Fix
max-muoto 6b85a45
Fixes
max-muoto 622360c
Tweak
max-muoto 9de2ab6
Add block
max-muoto 8190c3c
Nest _common
max-muoto 3f3ef73
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 61d4465
Fix
max-muoto 9cfef10
Fixes
max-muoto 46921b1
Fix
max-muoto db7f52c
Update stdlib/importlib/resources/__init__.pyi
max-muoto 60e7c31
Update stdlib/importlib/resources/__init__.pyi
max-muoto 51f9a42
Update stdlib/importlib/resources/__init__.pyi
max-muoto 8d16119
Update stdlib/importlib/resources/__init__.pyi
max-muoto 751673e
Update stdlib/@tests/test_cases/check_importlib_resources.py
max-muoto 141a6e8
Merge branch 'main' into importlib.resources
max-muoto 2587ba7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,35 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import importlib.resources | ||
| import pathlib | ||
| import sys | ||
|
|
||
|
|
||
| class _CustomPathLike: | ||
| def __init__(self, path: str) -> None: | ||
| self.path = path | ||
|
|
||
| def __fspath__(self) -> str: | ||
| return self.path | ||
|
|
||
|
|
||
| if sys.version_info >= (3, 13): | ||
|
|
||
| def f(pth: pathlib.Path | str | _CustomPathLike) -> None: | ||
| importlib.resources.open_binary("pkg", pth) | ||
| # Encoding defaults to "utf-8" for one arg. | ||
| importlib.resources.open_text("pkg", pth) | ||
| # Otherwise, it must be specified. | ||
| importlib.resources.open_text("pkg", pth, pth) # type: ignore | ||
| importlib.resources.open_text("pkg", pth, pth, encoding="utf-8") | ||
|
|
||
| # Encoding defaults to "utf-8" for one arg. | ||
| importlib.resources.read_text("pkg", pth) | ||
| # Otherwise, it must be specified. | ||
| importlib.resources.read_text("pkg", pth, pth) # type: ignore | ||
| importlib.resources.read_text("pkg", pth, pth, encoding="utf-8") | ||
|
|
||
| importlib.resources.read_binary("pkg", pth) | ||
| importlib.resources.path("pkg", pth) | ||
| importlib.resources.is_resource("pkg", pth) | ||
| importlib.resources.contents("pkg", pth) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,42 @@ | ||
| import sys | ||
|
|
||
| # Even though this file is 3.11+ only, Pyright will complain in stubtest for older versions. | ||
| if sys.version_info >= (3, 11): | ||
| import types | ||
| from collections.abc import Callable | ||
| from contextlib import AbstractContextManager | ||
| from importlib.abc import ResourceReader, Traversable | ||
| from pathlib import Path | ||
| from typing import overload | ||
| from typing_extensions import TypeAlias, deprecated | ||
|
|
||
| Package: TypeAlias = str | types.ModuleType | ||
|
|
||
| if sys.version_info >= (3, 12): | ||
| Anchor: TypeAlias = Package | ||
|
|
||
| def package_to_anchor( | ||
| func: Callable[[Anchor | None], Traversable] | ||
| ) -> Callable[[Anchor | None, Anchor | None], Traversable]: ... | ||
| @overload | ||
| def files(anchor: Anchor | None = None) -> Traversable: ... | ||
| @overload | ||
| @deprecated("First parameter to files is renamed to 'anchor'") | ||
| def files(package: Anchor | None = None) -> Traversable: ... | ||
|
|
||
| else: | ||
| def files(package: Package) -> Traversable: ... | ||
|
|
||
| def get_resource_reader(package: types.ModuleType) -> ResourceReader | None: ... | ||
|
|
||
| if sys.version_info >= (3, 12): | ||
| def resolve(cand: Anchor | None) -> types.ModuleType: ... | ||
|
|
||
| else: | ||
| def resolve(cand: Package) -> types.ModuleType: ... | ||
|
|
||
| if sys.version_info < (3, 12): | ||
| def get_package(package: Package) -> types.ModuleType: ... | ||
|
|
||
| def from_package(package: types.ModuleType) -> Traversable: ... | ||
| def as_file(path: Traversable) -> AbstractContextManager[Path]: ... |
This file contains hidden or 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,30 @@ | ||
| import sys | ||
|
|
||
| # Even though this file is 3.13+ only, Pyright will complain in stubtest for older versions. | ||
| if sys.version_info >= (3, 13): | ||
| from _typeshed import StrPath | ||
| from collections.abc import Iterator | ||
| from contextlib import AbstractContextManager | ||
| from importlib.resources._common import Anchor | ||
| from io import TextIOWrapper | ||
| from pathlib import Path | ||
| from typing import BinaryIO, overload | ||
| from typing_extensions import Unpack | ||
|
|
||
| def open_binary(anchor: Anchor, *path_names: StrPath) -> BinaryIO: ... | ||
| @overload | ||
| def open_text( | ||
| anchor: Anchor, *path_names: Unpack[tuple[StrPath]], encoding: str | None = "utf-8", errors: str | None = "strict" | ||
| ) -> TextIOWrapper: ... | ||
| @overload | ||
| def open_text(anchor: Anchor, *path_names: StrPath, encoding: str | None, errors: str | None = "strict") -> TextIOWrapper: ... | ||
| def read_binary(anchor: Anchor, *path_names: StrPath) -> bytes: ... | ||
| @overload | ||
| def read_text( | ||
| anchor: Anchor, *path_names: Unpack[tuple[StrPath]], encoding: str | None = "utf-8", errors: str | None = "strict" | ||
| ) -> str: ... | ||
| @overload | ||
| def read_text(anchor: Anchor, *path_names: StrPath, encoding: str | None, errors: str | None = "strict") -> str: ... | ||
| def path(anchor: Anchor, *path_names: StrPath) -> AbstractContextManager[Path]: ... | ||
| def is_resource(anchor: Anchor, *path_names: StrPath) -> bool: ... | ||
| def contents(anchor: Anchor, *path_names: StrPath) -> Iterator[str]: ... |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.