| 1 | Index: renpy-8.5.0-source/renpy/color.py
|
| 2 | ===================================================================
|
| 3 | |
| 4 | |
| 5 | @@ -19,7 +19,7 @@
|
| 6 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 7 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 8 |
|
| 9 | -from typing import final, overload
|
| 10 | +from typing import final, overload, ForwardRef
|
| 11 |
|
| 12 | import re
|
| 13 | import colorsys
|
| 14 | @@ -32,7 +32,7 @@ _LONG_COLOR_STRING_RE = re.compile(
|
| 15 | r"#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})?",
|
| 16 | )
|
| 17 |
|
| 18 | -type ColorLike = "Color" | tuple[int, int, int, int] | tuple[int, int, int] | str
|
| 19 | +type ColorLike = ForwardRef("Color") | tuple[int, int, int, int] | tuple[int, int, int] | str
|
| 20 | """
|
| 21 | The color, in one of the standard formats Ren'Py understands. These are:
|
| 22 | - A Color object.
|
| 23 | @@ -409,11 +409,11 @@ class Color(tuple[int, int, int, int]):
|
| 24 |
|
| 25 | __rmul__ = __mul__ # type: ignore
|
| 26 |
|
| 27 | - def _interpolate_tuple[T: tuple](self, a: T, b: T, fraction: float) -> T:
|
| 28 | + def _interpolate_tuple(self, a: tuple, b: tuple, fraction: float) -> tuple:
|
| 29 | i = self._interpolate_num
|
| 30 | return type(a)(tuple(i(ac, bc, fraction) for ac, bc in zip(a, b)))
|
| 31 |
|
| 32 | - def _interpolate_num[T: (float, int)](self, a: T, b: T, fraction: float) -> T:
|
| 33 | + def _interpolate_num(self, a: int | float, b: int | float, fraction: float) -> int | float:
|
| 34 | return type(a)(a + (b - a) * fraction)
|
| 35 |
|
| 36 | def interpolate(self, other: ColorLike, fraction: float) -> "Color":
|
| 37 | Index: renpy-8.5.0-source/renpy/cslots.pyi
|
| 38 | ===================================================================
|
| 39 | |
| 40 | |
| 41 | @@ -19,6 +19,8 @@
|
| 42 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 43 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 44 |
|
| 45 | +from typing import TypeVar, Generic
|
| 46 | +
|
| 47 | class Object:
|
| 48 | linenumber: int
|
| 49 | "If known, the line number of the object in the source file."
|
| 50 | @@ -45,7 +47,9 @@ class Object:
|
| 51 | and setting all slots to the default, breaking reference cycles.
|
| 52 | """
|
| 53 |
|
| 54 | -class Slot[T]:
|
| 55 | +T = TypeVar('T')
|
| 56 | +
|
| 57 | +class Slot(Generic(T)):
|
| 58 | number: int
|
| 59 | "A number assigned to this slot."
|
| 60 |
|
| 61 | Index: renpy-8.5.0-source/renpy/easy.py
|
| 62 | ===================================================================
|
| 63 | |
| 64 | |
| 65 | @@ -21,7 +21,7 @@
|
| 66 |
|
| 67 | """Functions that make the user's life easier."""
|
| 68 |
|
| 69 | -from typing import Any, Callable
|
| 70 | +from typing import Any, Callable, ParamSpec, TypeVar
|
| 71 | from collections.abc import Iterable
|
| 72 |
|
| 73 | import contextlib
|
| 74 | @@ -262,7 +262,10 @@ def split_properties(properties: dict[st
|
| 75 | return rv
|
| 76 |
|
| 77 |
|
| 78 | -def to_list[T](value: T | Iterable[T], copy: bool = False) -> list[T]:
|
| 79 | +T = TypeVar('T')
|
| 80 | +
|
| 81 | +
|
| 82 | +def to_list(value: T | Iterable[T], copy: bool = False) -> list[T]:
|
| 83 | """
|
| 84 | If the value is an iterable, turns it into a list, otherwise wraps it into one.
|
| 85 | If a list is provided and `copy` is True, a new list will be returned.
|
| 86 | @@ -281,7 +284,7 @@ def to_list[T](value: T | Iterable[T], c
|
| 87 | return [value]
|
| 88 |
|
| 89 |
|
| 90 | -def to_tuple[T](value: T | Iterable[T]) -> tuple[T, ...]:
|
| 91 | +def to_tuple(value: T | Iterable[T]) -> tuple[T, ...]:
|
| 92 | """
|
| 93 | Same as to_list, but with tuples.
|
| 94 | """
|
| 95 | @@ -299,7 +302,11 @@ def to_tuple[T](value: T | Iterable[T])
|
| 96 | return (value,)
|
| 97 |
|
| 98 |
|
| 99 | -def run_callbacks[**P, R](
|
| 100 | +P = ParamSpec('P')
|
| 101 | +R = TypeVar('R')
|
| 102 | +
|
| 103 | +
|
| 104 | +def run_callbacks(
|
| 105 | cb: Callable[P, R] | list[Callable[P, R]] | None,
|
| 106 | *args: P.args,
|
| 107 | **kwargs: P.kwargs,
|
| 108 | Index: renpy-8.5.0-source/renpy/display/position.py
|
| 109 | ===================================================================
|
| 110 | |
| 111 | |
| 112 | @@ -19,11 +19,14 @@
|
| 113 | # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
| 114 | # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 115 |
|
| 116 | -from typing import final, overload, SupportsIndex, Any
|
| 117 | +from typing import final, overload, SupportsIndex, Any, TypeVar
|
| 118 |
|
| 119 | from renpy.types import Position
|
| 120 |
|
| 121 |
|
| 122 | +T = TypeVar('T', int, float, "absolute")
|
| 123 | +
|
| 124 | +
|
| 125 | @final
|
| 126 | class absolute(float):
|
| 127 | """
|
| 128 | @@ -176,7 +179,7 @@ class absolute(float):
|
| 129 |
|
| 130 | @overload
|
| 131 | @staticmethod
|
| 132 | - def compute_raw[T: ("int | float | absolute")](value: T, room: float) -> T: ...
|
| 133 | + def compute_raw(value: T, room: float) -> T: ...
|
| 134 |
|
| 135 | @staticmethod
|
| 136 | def compute_raw(value: Position, room: float) -> "int | float | absolute":
|
| 137 | Index: renpy-8.5.0-source/renpy/types.py
|
| 138 | ===================================================================
|
| 139 | |
| 140 | |
| 141 | @@ -29,10 +29,11 @@
|
| 142 | # be inconvenient.
|
| 143 |
|
| 144 | import renpy
|
| 145 | +from typing import ForwardRef
|
| 146 |
|
| 147 | -type Displayable = renpy.display.displayable.Displayable
|
| 148 | +type Displayable = ForwardRef('renpy.display.displayable.Displayable')
|
| 149 |
|
| 150 | -type DisplayableLike = Displayable | str | list[str] | renpy.color.Color
|
| 151 | +type DisplayableLike = Displayable | str | list[str] | ForwardRef('renpy.color.Color')
|
| 152 | """
|
| 153 | This describes anything that Ren'Py considers to be a displayable.
|
| 154 |
|
| 155 | @@ -45,7 +46,7 @@ Apart from Displayable itself, this coul
|
| 156 | - renpy.color.Color object.
|
| 157 | """
|
| 158 |
|
| 159 | -type Position = int | float | renpy.display.position.absolute | renpy.display.position.position
|
| 160 | +type Position = int | float | ForwardRef('renpy.display.position.absolute') | ForwardRef('renpy.display.position.position')
|
| 161 | """
|
| 162 | This describes a position, which can be one of:
|
| 163 | - An integer - treated as pixels from the top left corner of the area.
|
| 164 | Index: renpy-8.5.0-source/renpy/__init__.py
|
| 165 | ===================================================================
|
| 166 | |
| 167 | |
| 168 | @@ -227,6 +227,7 @@ backup_blacklist = {
|
| 169 | "renpy.test.testreporter",
|
| 170 | "renpy.test.testsettings",
|
| 171 | "renpy.tfd",
|
| 172 | + "renpy.types",
|
| 173 | "renpy.gl2",
|
| 174 | "renpycoverage",
|
| 175 | }
|
| 176 | @@ -245,9 +246,13 @@ name_blacklist = {
|
| 177 | "renpy.savelocation.disk_lock",
|
| 178 | "renpy.character.TAG_RE",
|
| 179 | + "renpy.color.ColorLike",
|
| 180 | "renpy.display.im.cache",
|
| 181 | + "renpy.display.position.Position",
|
| 182 | "renpy.display.render.main_thread",
|
| 183 | "renpy.display.render.blit_lock",
|
| 184 | "renpy.display.render.IDENTITY",
|
| 185 | + "renpy.easy.Displayable",
|
| 186 | + "renpy.easy.DisplayableLike",
|
| 187 | "renpy.loader.auto_lock",
|
| 188 | "renpy.display.screen.cprof",
|
| 189 | "renpy.audio.audio.lock",
|