mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-03-06 23:24:25 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -2,7 +2,7 @@ from _typeshed import Self, SupportsRead, SupportsWrite
|
||||
from collections.abc import Iterable, Iterator, MutableMapping
|
||||
from pathlib import Path
|
||||
from typing import Any, Callable, ClassVar, Protocol, Sequence, SupportsBytes, Union
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from ._imaging import (
|
||||
DEFAULT_STRATEGY as DEFAULT_STRATEGY,
|
||||
@@ -14,15 +14,15 @@ from ._imaging import (
|
||||
from .ImageFilter import Filter
|
||||
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]
|
||||
_Mode: TypeAlias = Literal["1", "CMYK", "F", "HSV", "I", "L", "LAB", "P", "RGB", "RGBA", "RGBX", "YCbCr"]
|
||||
_Resample: TypeAlias = Literal[0, 1, 2, 3, 4, 5]
|
||||
_Size: TypeAlias = tuple[int, int]
|
||||
_Box: TypeAlias = tuple[int, int, int, int]
|
||||
|
||||
_ConversionMatrix = Union[
|
||||
_ConversionMatrix: TypeAlias = Union[
|
||||
tuple[float, float, float, float], tuple[float, float, float, float, float, float, float, float, float, float, float, float],
|
||||
]
|
||||
_Color = float | tuple[float, ...]
|
||||
_Color: TypeAlias = float | tuple[float, ...]
|
||||
|
||||
class _Writeable(SupportsWrite[bytes], Protocol):
|
||||
def seek(self, __offset: int) -> Any: ...
|
||||
@@ -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: TypeAlias = tuple[dict[str, Any], str, tuple[int, int], Any, bytes]
|
||||
|
||||
class Image:
|
||||
format: ClassVar[str | None]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from typing import Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_RGB = Union[tuple[int, int, int], tuple[int, int, int, int]]
|
||||
_Ink = str | int | _RGB
|
||||
_GreyScale = tuple[int, int]
|
||||
_RGB: TypeAlias = Union[tuple[int, int, int], tuple[int, int, int, int]]
|
||||
_Ink: TypeAlias = str | int | _RGB
|
||||
_GreyScale: TypeAlias = tuple[int, int]
|
||||
|
||||
def getrgb(color: _Ink) -> _RGB: ...
|
||||
def getcolor(color: _Ink, mode: str) -> _RGB | _GreyScale: ...
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from collections.abc import Container
|
||||
from typing import Any, Sequence, overload
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .Image import Image
|
||||
from .ImageColor import _Ink
|
||||
from .ImageFont import _Font
|
||||
|
||||
_XY = Sequence[float | tuple[float, float]]
|
||||
_Outline = Any
|
||||
_XY: TypeAlias = Sequence[float | tuple[float, float]]
|
||||
_Outline: TypeAlias = Any
|
||||
|
||||
class ImageDraw:
|
||||
def __init__(self, im: Image, mode: str | None = ...) -> None: ...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from typing import Any, Callable, Iterable, Sequence
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
from .Image import Image
|
||||
|
||||
_FilterArgs = tuple[Sequence[int], int, int, Sequence[int]]
|
||||
_FilterArgs: TypeAlias = tuple[Sequence[int], int, int, Sequence[int]]
|
||||
|
||||
# filter image parameters below are the C images, i.e. Image().im.
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
from typing import Any, Iterable, Protocol, Union
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
from .Image import Image, _Resample, _Size
|
||||
from .ImageColor import _Ink
|
||||
|
||||
_Border = Union[int, tuple[int, int], tuple[int, int, int, int]]
|
||||
_Border: TypeAlias = Union[int, tuple[int, int], tuple[int, int, int, int]]
|
||||
|
||||
class _Deformer(Protocol):
|
||||
def getmesh(self, image: Image): ...
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from typing import Any, NamedTuple, Union
|
||||
from typing_extensions import Literal
|
||||
from typing_extensions import Literal, TypeAlias
|
||||
|
||||
class _TagInfo(NamedTuple):
|
||||
value: Any
|
||||
@@ -35,8 +35,8 @@ FLOAT: Literal[11]
|
||||
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]]]
|
||||
_TagType: TypeAlias = Literal[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
||||
_TagTuple: TypeAlias = 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