mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-19 23:09:55 +08:00
Use PEP 585 syntax wherever possible (#6717)
This commit is contained in:
+10
-10
@@ -1,7 +1,7 @@
|
||||
from _typeshed import SupportsRead, SupportsWrite
|
||||
from collections.abc import Iterable, Iterator, MutableMapping
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, Dict, Protocol, Sequence, SupportsBytes, Tuple, Union
|
||||
from typing import Any, Callable, Protocol, Sequence, SupportsBytes, Union
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ._imaging import (
|
||||
@@ -16,13 +16,13 @@ from .ImagePalette import ImagePalette
|
||||
|
||||
_Mode = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"]
|
||||
_Resample = Literal[0, 1, 2, 3, 4, 5]
|
||||
_Size = Tuple[int, int]
|
||||
_Box = Tuple[int, int, int, int]
|
||||
_Size = tuple[int, int]
|
||||
_Box = tuple[int, int, int, int]
|
||||
|
||||
_ConversionMatrix = Union[
|
||||
Tuple[float, float, float, float], Tuple[float, float, float, float, float, float, float, float, float, float, float, float],
|
||||
tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float],
|
||||
]
|
||||
_Color = Union[float, Tuple[float, ...]]
|
||||
_Color = Union[float, tuple[float, ...]]
|
||||
|
||||
class _Writeable(SupportsWrite[bytes], Protocol):
|
||||
def seek(self, __offset: int) -> Any: ...
|
||||
@@ -88,7 +88,7 @@ MODES: list[_Mode]
|
||||
|
||||
def getmodebase(mode: _Mode) -> Literal["L", "RGB"]: ...
|
||||
def getmodetype(mode: _Mode) -> Literal["L", "I", "F"]: ...
|
||||
def getmodebandnames(mode: _Mode) -> Tuple[str, ...]: ...
|
||||
def getmodebandnames(mode: _Mode) -> tuple[str, ...]: ...
|
||||
def getmodebands(mode: _Mode) -> int: ...
|
||||
def preinit() -> None: ...
|
||||
def init() -> None: ...
|
||||
@@ -99,7 +99,7 @@ class _E:
|
||||
def __add__(self, other) -> _E: ...
|
||||
def __mul__(self, other) -> _E: ...
|
||||
|
||||
_ImageState = Tuple[Dict[str, Any], str, Tuple[int, int], Any, bytes]
|
||||
_ImageState = tuple[dict[str, Any], str, tuple[int, int], Any, bytes]
|
||||
|
||||
class Image:
|
||||
format: Any
|
||||
@@ -149,7 +149,7 @@ class Image:
|
||||
def crop(self, box: _Box | None = ...) -> Image: ...
|
||||
def draft(self, mode: str, size: _Size) -> None: ...
|
||||
def filter(self, filter: Filter | Callable[[], Filter]) -> Image: ...
|
||||
def getbands(self) -> Tuple[str, ...]: ...
|
||||
def getbands(self) -> tuple[str, ...]: ...
|
||||
def getbbox(self) -> tuple[int, int, int, int] | None: ...
|
||||
def getcolors(self, maxcolors: int = ...) -> list[tuple[int, int]]: ...
|
||||
def getdata(self, band: int | None = ...): ...
|
||||
@@ -197,7 +197,7 @@ class Image:
|
||||
) -> None: ...
|
||||
def seek(self, frame: int) -> None: ...
|
||||
def show(self, title: str | None = ..., command: str | None = ...) -> None: ...
|
||||
def split(self) -> Tuple[Image, ...]: ...
|
||||
def split(self) -> tuple[Image, ...]: ...
|
||||
def getchannel(self, channel: int | str) -> Image: ...
|
||||
def tell(self) -> int: ...
|
||||
def thumbnail(self, size: tuple[int, int], resample: _Resample = ..., reducing_gap: float = ...) -> None: ...
|
||||
@@ -218,7 +218,7 @@ class Image:
|
||||
class ImagePointHandler: ...
|
||||
class ImageTransformHandler: ...
|
||||
|
||||
def new(mode: _Mode, size: tuple[int, int], color: float | Tuple[float, ...] | str = ...) -> Image: ...
|
||||
def new(mode: _Mode, size: tuple[int, int], color: float | tuple[float, ...] | str = ...) -> Image: ...
|
||||
def frombytes(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ...
|
||||
def frombuffer(mode: _Mode, size: tuple[int, int], data, decoder_name: str = ..., *args) -> Image: ...
|
||||
def fromarray(obj, mode: _Mode | None = ...) -> Image: ...
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from typing import Tuple, Union
|
||||
from typing import Union
|
||||
|
||||
_RGB = Union[Tuple[int, int, int], Tuple[int, int, int, int]]
|
||||
_RGB = Union[tuple[int, int, int], tuple[int, int, int, int]]
|
||||
_Ink = Union[str, int, _RGB]
|
||||
_GreyScale = Tuple[int, int]
|
||||
_GreyScale = tuple[int, int]
|
||||
|
||||
def getrgb(color: _Ink) -> _RGB: ...
|
||||
def getcolor(color: _Ink, mode: str) -> _RGB | _GreyScale: ...
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from collections.abc import Container
|
||||
from typing import Any, Sequence, Tuple, Union, overload
|
||||
from typing import Any, Sequence, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .Image import Image
|
||||
from .ImageColor import _Ink
|
||||
from .ImageFont import _Font
|
||||
|
||||
_XY = Sequence[Union[float, Tuple[float, float]]]
|
||||
_XY = Sequence[Union[float, tuple[float, float]]]
|
||||
_Outline = Any
|
||||
|
||||
class ImageDraw:
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Iterable, Sequence, Tuple, Type
|
||||
from typing import Any, Callable, Iterable, Sequence, Type
|
||||
from typing_extensions import Literal
|
||||
|
||||
from .Image import Image
|
||||
|
||||
_FilterArgs = Tuple[Sequence[int], int, int, Sequence[int]]
|
||||
_FilterArgs = tuple[Sequence[int], int, int, Sequence[int]]
|
||||
|
||||
# filter image parameters below are the C images, i.e. Image().im.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import collections
|
||||
from typing import Any, List
|
||||
from typing import Any
|
||||
|
||||
def encode_text(s: str) -> bytes: ...
|
||||
|
||||
@@ -44,7 +44,7 @@ class PdfName:
|
||||
allowed_chars: Any
|
||||
def __bytes__(self): ...
|
||||
|
||||
class PdfArray(List[Any]):
|
||||
class PdfArray(list[Any]):
|
||||
def __bytes__(self): ...
|
||||
|
||||
class PdfDict(collections.UserDict):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Dict, NamedTuple, Tuple, Union
|
||||
from typing import Any, NamedTuple, Union
|
||||
from typing_extensions import Literal
|
||||
|
||||
class _TagInfo(NamedTuple):
|
||||
@@ -36,7 +36,7 @@ DOUBLE: Literal[12]
|
||||
IFD: Literal[13]
|
||||
|
||||
_TagType = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
||||
_TagTuple = Union[Tuple[str, _TagType, int], Tuple[str, _TagInfo, int, Dict[str, int]]]
|
||||
_TagTuple = Union[tuple[str, _TagType, int], tuple[str, _TagInfo, int, dict[str, int]]]
|
||||
|
||||
TAGS_V2: dict[int, _TagTuple]
|
||||
TAGS_V2_GROUPS: dict[int, dict[int, _TagTuple]]
|
||||
|
||||
Reference in New Issue
Block a user