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,6 +1,6 @@
import sys
import types
from _typeshed import AnyPath
from _typeshed import StrOrBytesPath
from abc import ABCMeta, abstractmethod
from importlib.machinery import ModuleSpec
from typing import IO, Any, Iterator, Mapping, Optional, Protocol, Sequence, Tuple, Union
@@ -73,9 +73,9 @@ class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta):
if sys.version_info >= (3, 7):
class ResourceReader(metaclass=ABCMeta):
@abstractmethod
def open_resource(self, resource: AnyPath) -> IO[bytes]: ...
def open_resource(self, resource: StrOrBytesPath) -> IO[bytes]: ...
@abstractmethod
def resource_path(self, resource: AnyPath) -> str: ...
def resource_path(self, resource: StrOrBytesPath) -> str: ...
@abstractmethod
def is_resource(self, name: str) -> bool: ...
@abstractmethod

View File

@@ -1,7 +1,7 @@
import importlib.abc
import importlib.machinery
import types
from _typeshed import AnyPath
from _typeshed import StrOrBytesPath
from typing import Any, Callable, List, Optional
def module_for_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ...
@@ -20,7 +20,7 @@ def spec_from_loader(
) -> Optional[importlib.machinery.ModuleSpec]: ...
def spec_from_file_location(
name: str,
location: Optional[AnyPath] = ...,
location: Optional[StrOrBytesPath] = ...,
*,
loader: Optional[importlib.abc.Loader] = ...,
submodule_search_locations: Optional[List[str]] = ...,