DefaultDict -> defaultdict, typing.ContextManager -> contextlib.AbstractContextManager (#6351)

This commit is contained in:
Alex Waygood
2021-11-21 15:07:35 +00:00
committed by GitHub
parent 5b668419ae
commit dc5f6410a8
3 changed files with 8 additions and 7 deletions

View File

@@ -4,9 +4,10 @@ from typing import Any
# 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, ContextManager, Iterator, TextIO, Union
from typing import BinaryIO, Iterator, TextIO, Union
Package = Union[str, ModuleType]
Resource = Union[str, os.PathLike[Any]]
@@ -14,12 +15,11 @@ if sys.version_info >= (3, 7):
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 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 contextlib import AbstractContextManager
from importlib.abc import Traversable
def files(package: Package) -> Traversable: ...
def as_file(path: Traversable) -> AbstractContextManager[Path]: ...