Use PEP 604 syntax wherever possible (#7493)

This commit is contained in:
Alex Waygood
2022-03-16 15:01:33 +00:00
committed by GitHub
parent 15e21a8dc1
commit 3ab250eec8
174 changed files with 472 additions and 490 deletions

View File

@@ -12,10 +12,10 @@ from _typeshed import (
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, Union, overload, runtime_checkable
from typing import IO, Any, BinaryIO, Iterator, Mapping, NoReturn, Protocol, Sequence, overload, runtime_checkable
from typing_extensions import Literal
_Path = Union[bytes, str]
_Path = bytes | str
class Finder(metaclass=ABCMeta): ...

View File

@@ -3,7 +3,7 @@ import sys
from contextlib import AbstractContextManager
from pathlib import Path
from types import ModuleType
from typing import Any, BinaryIO, Iterator, TextIO, Union
from typing import Any, BinaryIO, Iterator, TextIO
if sys.version_info >= (3, 10):
__all__ = [
@@ -37,8 +37,8 @@ elif sys.version_info >= (3, 9):
else:
__all__ = ["Package", "Resource", "contents", "is_resource", "open_binary", "open_text", "path", "read_binary", "read_text"]
Package = Union[str, ModuleType]
Resource = Union[str, os.PathLike[Any]]
Package = str | ModuleType
Resource = str | os.PathLike[Any]
def open_binary(package: Package, resource: Resource) -> BinaryIO: ...
def open_text(package: Package, resource: Resource, encoding: str = ..., errors: str = ...) -> TextIO: ...