mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-23 19:41:51 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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]] = ...,
|
||||
|
||||
Reference in New Issue
Block a user