AnyStr cleanup (#5487)

* Replace all uses of StrPath, BytesPath, and AnyPath in Python 2 stubs.
* Add StrOrBytesPath as preferred alias for AnyPath.
* Replace all remaining AnyPath instances with StrOrBytesPath.
* Mark AnyPath as obsolete.

Part of #5470
This commit is contained in:
Sebastian Rittau
2021-05-17 20:45:48 +02:00
committed by GitHub
parent 51b7248154
commit f0bf6eebbd
67 changed files with 546 additions and 529 deletions

View File

@@ -1,12 +1,12 @@
import io
from _typeshed import AnyPath, ReadableBuffer
from _typeshed import ReadableBuffer, StrOrBytesPath
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
from typing_extensions import Literal
_OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"]
_OpenTextWritingMode = Literal["wt", "xt", "at"]
_PathOrFile = Union[AnyPath, IO[bytes]]
_PathOrFile = Union[StrOrBytesPath, IO[bytes]]
_FilterChain = Sequence[Mapping[str, Any]]
_T = TypeVar("_T")
@@ -120,7 +120,7 @@ def open(
) -> LZMAFile: ...
@overload
def open(
filename: AnyPath,
filename: StrOrBytesPath,
mode: Literal["rt"],
*,
format: Optional[int] = ...,
@@ -133,7 +133,7 @@ def open(
) -> TextIO: ...
@overload
def open(
filename: AnyPath,
filename: StrOrBytesPath,
mode: _OpenTextWritingMode,
*,
format: Optional[int] = ...,