mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-29 23:26:54 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -13,9 +13,9 @@ from abc import ABCMeta, abstractmethod
|
||||
from importlib.machinery import ModuleSpec
|
||||
from io import BufferedRandom, BufferedReader, BufferedWriter, FileIO, TextIOWrapper
|
||||
from typing import IO, Any, BinaryIO, Iterator, Mapping, NoReturn, Protocol, Sequence, overload, runtime_checkable
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
_Path = bytes | str
|
||||
_Path: TypeAlias = bytes | str
|
||||
|
||||
class Finder(metaclass=ABCMeta): ...
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from contextlib import AbstractContextManager
|
||||
from pathlib import Path
|
||||
from types import ModuleType
|
||||
from typing import Any, BinaryIO, Iterator, TextIO
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 10):
|
||||
__all__ = [
|
||||
@@ -37,8 +38,8 @@ elif sys.version_info >= (3, 9):
|
||||
else:
|
||||
__all__ = ["Package", "Resource", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"]
|
||||
|
||||
Package = str | ModuleType
|
||||
Resource = str | os.PathLike[Any]
|
||||
Package: TypeAlias = str | ModuleType
|
||||
Resource: TypeAlias = str | os.PathLike[Any]
|
||||
|
||||
def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
|
||||
def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ...
|
||||
|
||||
Reference in New Issue
Block a user