-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Source commit: python/typeshed@a94c927
- Loading branch information
Showing
9 changed files
with
254 additions
and
41 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
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,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 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]: ... |
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
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