Clean up several version-dependent modules (#6885)

This commit is contained in:
Alex Waygood
2022-01-10 13:57:08 +00:00
committed by GitHub
parent a8c9c194b4
commit 7d33ff330a
11 changed files with 142 additions and 148 deletions

View File

@@ -1,23 +1,20 @@
import os
import sys
from typing import Any
from contextlib import AbstractContextManager
from pathlib import Path
from types import ModuleType
from typing import Any, BinaryIO, Iterator, TextIO, Union
# This is a >=3.7 module, so we conditionally include its source.
if sys.version_info >= (3, 7):
import os
from contextlib import AbstractContextManager
from pathlib import Path
from types import ModuleType
from typing import BinaryIO, Iterator, TextIO, Union
Package = Union[str, ModuleType]
Resource = Union[str, os.PathLike[Any]]
Package = Union[str, ModuleType]
Resource = Union[str, os.PathLike[Any]]
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) -> AbstractContextManager[Path]: ...
def is_resource(package: Package, name: str) -> bool: ...
def contents(package: Package) -> Iterator[str]: ...
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) -> AbstractContextManager[Path]: ...
def is_resource(package: Package, name: str) -> bool: ...
def contents(package: Package) -> Iterator[str]: ...
if sys.version_info >= (3, 9):
from importlib.abc import Traversable