diff --git a/stdlib/3.7/importlib/resources.pyi b/stdlib/3.7/importlib/resources.pyi deleted file mode 100644 index 57dc7b9f24c6..000000000000 --- a/stdlib/3.7/importlib/resources.pyi +++ /dev/null @@ -1,22 +0,0 @@ -import os - -from pathlib import Path -from types import ModuleType -from typing import ContextManager, Iterator, Union, BinaryIO, TextIO - -Package = Union[str, ModuleType] -Resource = Union[str, os.PathLike] - -def open_binary(package: Package, resource: Resource) -> BinaryIO: ... -def open_text(package: Package, - resource: Resource, - encoding: str = ..., - errors: str = ...) -> TextIO: ... -def read_binary(package: Package, resource: Resource) -> bytes: ... -def read_text(package: Package, - resource: Resource, - encoding: str = ..., - errors: str = ...) -> str: ... -def path(package: Package, resource: Resource) -> ContextManager[Path]: ... -def is_resource(package: Package, name: str) -> bool: ... -def contents(package: Package) -> Iterator[str]: ... diff --git a/stdlib/3/importlib/resources.pyi b/stdlib/3/importlib/resources.pyi new file mode 100644 index 000000000000..2db82b32641f --- /dev/null +++ b/stdlib/3/importlib/resources.pyi @@ -0,0 +1,25 @@ +import sys +# This is a >=3.7 module, so we conditionally include its source. +if sys.version_info >= (3, 7): + import os + + from pathlib import Path + from types import ModuleType + from typing import ContextManager, Iterator, Union, BinaryIO, TextIO + + Package = Union[str, ModuleType] + Resource = Union[str, os.PathLike] + + def open_binary(package: Package, resource: Resource) -> BinaryIO: ... + def open_text(package: Package, + resource: Resource, + encoding: str = ..., + errors: str = ...) -> TextIO: ... + def read_binary(package: Package, resource: Resource) -> bytes: ... + def read_text(package: Package, + resource: Resource, + encoding: str = ..., + errors: str = ...) -> str: ... + def path(package: Package, resource: Resource) -> ContextManager[Path]: ... + def is_resource(package: Package, name: str) -> bool: ... + def contents(package: Package) -> Iterator[str]: ...