Use the FileDescriptorOrPath alias consistently in the stdlib (#9513)

This commit is contained in:
Avasam
2023-01-12 13:14:48 -05:00
committed by GitHub
parent f64807a468
commit aad1a14890
12 changed files with 61 additions and 57 deletions

View File

@@ -1,5 +1,5 @@
import sys
from _typeshed import StrOrBytesPath
from _typeshed import FileDescriptorOrPath
from collections.abc import Callable
from xml.etree.ElementTree import Element
@@ -12,7 +12,7 @@ if sys.version_info >= (3, 9):
class FatalIncludeError(SyntaxError): ...
def default_loader(href: StrOrBytesPath | int, parse: str, encoding: str | None = ...) -> str | Element: ...
def default_loader(href: FileDescriptorOrPath, parse: str, encoding: str | None = ...) -> str | Element: ...
# TODO: loader is of type default_loader ie it takes a callable that has the
# same signature as default_loader. But default_loader has a keyword argument

View File

@@ -1,6 +1,6 @@
import sys
from _collections_abc import dict_keys
from _typeshed import FileDescriptor, ReadableBuffer, StrOrBytesPath, SupportsRead, SupportsWrite
from _typeshed import FileDescriptorOrPath, ReadableBuffer, SupportsRead, SupportsWrite
from collections.abc import Callable, Generator, ItemsView, Iterable, Iterator, Mapping, Sequence
from typing import Any, TypeVar, overload
from typing_extensions import Literal, SupportsIndex, TypeAlias, TypeGuard
@@ -38,8 +38,8 @@ if sys.version_info >= (3, 9):
__all__ += ["indent"]
_T = TypeVar("_T")
_FileRead: TypeAlias = StrOrBytesPath | FileDescriptor | SupportsRead[bytes] | SupportsRead[str]
_FileWriteC14N: TypeAlias = StrOrBytesPath | FileDescriptor | SupportsWrite[bytes]
_FileRead: TypeAlias = FileDescriptorOrPath | SupportsRead[bytes] | SupportsRead[str]
_FileWriteC14N: TypeAlias = FileDescriptorOrPath | SupportsWrite[bytes]
_FileWrite: TypeAlias = _FileWriteC14N | SupportsWrite[str]
VERSION: str