Use typing_extensions.Self instead of _typeshed.Self (#9702)

This commit is contained in:
Alex Waygood
2023-02-15 11:32:43 +01:00
committed by GitHub
parent 8cd6d81f15
commit 7180d0223b
140 changed files with 597 additions and 610 deletions

View File

@@ -1,11 +1,11 @@
import decimal
from _typeshed import Incomplete, Self
from _typeshed import Incomplete
from collections import OrderedDict
from collections.abc import Callable, Generator, Iterator
from contextlib import contextmanager
from re import Pattern
from typing import Any, ClassVar, NamedTuple, TypeVar
from typing_extensions import TypeAlias
from typing_extensions import Self, TypeAlias
from .syntax import Name, Raw
@@ -38,7 +38,7 @@ class _DeviceRGBBase(NamedTuple):
class DeviceRGB(_DeviceRGBBase):
OPERATOR: ClassVar[str]
def __new__(cls: type[Self], r: Number, g: Number, b: Number, a: Number | None = ...) -> Self: ...
def __new__(cls, r: Number, g: Number, b: Number, a: Number | None = ...) -> Self: ...
@property
def colors(self) -> tuple[Number, Number, Number]: ...
def serialize(self) -> str: ...
@@ -49,7 +49,7 @@ class _DeviceGrayBase(NamedTuple):
class DeviceGray(_DeviceGrayBase):
OPERATOR: ClassVar[str]
def __new__(cls: type[Self], g: Number, a: Number | None = ...) -> Self: ...
def __new__(cls, g: Number, a: Number | None = ...) -> Self: ...
@property
def colors(self) -> tuple[Number]: ...
def serialize(self) -> str: ...
@@ -63,7 +63,7 @@ class _DeviceCMYKBase(NamedTuple):
class DeviceCMYK(_DeviceCMYKBase):
OPERATOR: ClassVar[str]
def __new__(cls: type[Self], c: Number, m: Number, y: Number, k: Number, a: Number | None = ...) -> Self: ...
def __new__(cls, c: Number, m: Number, y: Number, k: Number, a: Number | None = ...) -> Self: ...
@property
def colors(self) -> tuple[Number, Number, Number, Number]: ...
def serialize(self) -> str: ...
@@ -128,7 +128,7 @@ class GraphicsStyle:
@classmethod
def merge(cls, parent, child): ...
def __init__(self) -> None: ...
def __deepcopy__(self: Self, memo) -> Self: ...
def __deepcopy__(self, memo) -> Self: ...
@property
def allow_transparency(self): ...
@allow_transparency.setter
@@ -322,7 +322,7 @@ class DrawingContext:
class PaintedPath:
def __init__(self, x: int = ..., y: int = ...) -> None: ...
def __deepcopy__(self: Self, memo) -> Self: ...
def __deepcopy__(self, memo) -> Self: ...
@property
def style(self): ...
@property
@@ -342,26 +342,26 @@ class PaintedPath:
@clipping_path.setter
def clipping_path(self, new_clipath) -> None: ...
@contextmanager
def transform_group(self: Self, transform) -> Iterator[Self]: ...
def transform_group(self, transform) -> Iterator[Self]: ...
def add_path_element(self, item, _copy: bool = ...) -> None: ...
def remove_last_path_element(self) -> None: ...
def rectangle(self: Self, x, y, w, h, rx: int = ..., ry: int = ...) -> Self: ...
def circle(self: Self, cx, cy, r) -> Self: ...
def ellipse(self: Self, cx, cy, rx, ry) -> Self: ...
def move_to(self: Self, x, y) -> Self: ...
def move_relative(self: Self, x, y) -> Self: ...
def line_to(self: Self, x, y) -> Self: ...
def line_relative(self: Self, dx, dy) -> Self: ...
def horizontal_line_to(self: Self, x) -> Self: ...
def horizontal_line_relative(self: Self, dx) -> Self: ...
def vertical_line_to(self: Self, y) -> Self: ...
def vertical_line_relative(self: Self, dy) -> Self: ...
def curve_to(self: Self, x1, y1, x2, y2, x3, y3) -> Self: ...
def curve_relative(self: Self, dx1, dy1, dx2, dy2, dx3, dy3) -> Self: ...
def quadratic_curve_to(self: Self, x1, y1, x2, y2) -> Self: ...
def quadratic_curve_relative(self: Self, dx1, dy1, dx2, dy2) -> Self: ...
def arc_to(self: Self, rx, ry, rotation, large_arc, positive_sweep, x, y) -> Self: ...
def arc_relative(self: Self, rx, ry, rotation, large_arc, positive_sweep, dx, dy) -> Self: ...
def rectangle(self, x, y, w, h, rx: int = ..., ry: int = ...) -> Self: ...
def circle(self, cx, cy, r) -> Self: ...
def ellipse(self, cx, cy, rx, ry) -> Self: ...
def move_to(self, x, y) -> Self: ...
def move_relative(self, x, y) -> Self: ...
def line_to(self, x, y) -> Self: ...
def line_relative(self, dx, dy) -> Self: ...
def horizontal_line_to(self, x) -> Self: ...
def horizontal_line_relative(self, dx) -> Self: ...
def vertical_line_to(self, y) -> Self: ...
def vertical_line_relative(self, dy) -> Self: ...
def curve_to(self, x1, y1, x2, y2, x3, y3) -> Self: ...
def curve_relative(self, dx1, dy1, dx2, dy2, dx3, dy3) -> Self: ...
def quadratic_curve_to(self, x1, y1, x2, y2) -> Self: ...
def quadratic_curve_relative(self, dx1, dy1, dx2, dy2) -> Self: ...
def arc_to(self, rx, ry, rotation, large_arc, positive_sweep, x, y) -> Self: ...
def arc_relative(self, rx, ry, rotation, large_arc, positive_sweep, dx, dy) -> Self: ...
def close(self) -> None: ...
def render(
self, gsd_registry, style, last_item, initial_point, debug_stream: Incomplete | None = ..., pfx: Incomplete | None = ...
@@ -380,7 +380,7 @@ class GraphicsContext:
style: GraphicsStyle
path_items: list[Incomplete]
def __init__(self) -> None: ...
def __deepcopy__(self: Self, memo) -> Self: ...
def __deepcopy__(self, memo) -> Self: ...
@property
def transform(self) -> Transform | None: ...
@transform.setter

View File

@@ -1,6 +1,5 @@
from _typeshed import Self
from enum import Enum, Flag, IntEnum, IntFlag
from typing_extensions import Literal
from typing_extensions import Literal, Self
from .syntax import Name
@@ -10,11 +9,11 @@ class SignatureFlag(IntEnum):
class CoerciveEnum(Enum):
@classmethod
def coerce(cls: type[Self], value: Self | str) -> Self: ...
def coerce(cls, value: Self | str) -> Self: ...
class CoerciveIntEnum(IntEnum):
@classmethod
def coerce(cls: type[Self], value: Self | str | int) -> Self: ...
def coerce(cls, value: Self | str | int) -> Self: ...
class CharVPos(CoerciveEnum):
SUP: str