runwayml 2.2.0__py3-none-any.whl → 2.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- runwayml/_models.py +7 -1
- runwayml/_utils/_sync.py +17 -2
- runwayml/_utils/_transform.py +11 -1
- runwayml/_version.py +1 -1
- {runwayml-2.2.0.dist-info → runwayml-2.2.2.dist-info}/METADATA +1 -1
- {runwayml-2.2.0.dist-info → runwayml-2.2.2.dist-info}/RECORD +8 -8
- {runwayml-2.2.0.dist-info → runwayml-2.2.2.dist-info}/WHEEL +0 -0
- {runwayml-2.2.0.dist-info → runwayml-2.2.2.dist-info}/licenses/LICENSE +0 -0
runwayml/_models.py
CHANGED
@@ -426,10 +426,16 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
426
426
|
|
427
427
|
If the given value does not match the expected type then it is returned as-is.
|
428
428
|
"""
|
429
|
+
|
430
|
+
# store a reference to the original type we were given before we extract any inner
|
431
|
+
# types so that we can properly resolve forward references in `TypeAliasType` annotations
|
432
|
+
original_type = None
|
433
|
+
|
429
434
|
# we allow `object` as the input type because otherwise, passing things like
|
430
435
|
# `Literal['value']` will be reported as a type error by type checkers
|
431
436
|
type_ = cast("type[object]", type_)
|
432
437
|
if is_type_alias_type(type_):
|
438
|
+
original_type = type_ # type: ignore[unreachable]
|
433
439
|
type_ = type_.__value__ # type: ignore[unreachable]
|
434
440
|
|
435
441
|
# unwrap `Annotated[T, ...]` -> `T`
|
@@ -446,7 +452,7 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
446
452
|
|
447
453
|
if is_union(origin):
|
448
454
|
try:
|
449
|
-
return validate_type(type_=cast("type[object]", type_), value=value)
|
455
|
+
return validate_type(type_=cast("type[object]", original_type or type_), value=value)
|
450
456
|
except Exception:
|
451
457
|
pass
|
452
458
|
|
runwayml/_utils/_sync.py
CHANGED
@@ -7,16 +7,20 @@ import contextvars
|
|
7
7
|
from typing import Any, TypeVar, Callable, Awaitable
|
8
8
|
from typing_extensions import ParamSpec
|
9
9
|
|
10
|
+
import anyio
|
11
|
+
import sniffio
|
12
|
+
import anyio.to_thread
|
13
|
+
|
10
14
|
T_Retval = TypeVar("T_Retval")
|
11
15
|
T_ParamSpec = ParamSpec("T_ParamSpec")
|
12
16
|
|
13
17
|
|
14
18
|
if sys.version_info >= (3, 9):
|
15
|
-
|
19
|
+
_asyncio_to_thread = asyncio.to_thread
|
16
20
|
else:
|
17
21
|
# backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
|
18
22
|
# for Python 3.8 support
|
19
|
-
async def
|
23
|
+
async def _asyncio_to_thread(
|
20
24
|
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
|
21
25
|
) -> Any:
|
22
26
|
"""Asynchronously run function *func* in a separate thread.
|
@@ -34,6 +38,17 @@ else:
|
|
34
38
|
return await loop.run_in_executor(None, func_call)
|
35
39
|
|
36
40
|
|
41
|
+
async def to_thread(
|
42
|
+
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
|
43
|
+
) -> T_Retval:
|
44
|
+
if sniffio.current_async_library() == "asyncio":
|
45
|
+
return await _asyncio_to_thread(func, *args, **kwargs)
|
46
|
+
|
47
|
+
return await anyio.to_thread.run_sync(
|
48
|
+
functools.partial(func, *args, **kwargs),
|
49
|
+
)
|
50
|
+
|
51
|
+
|
37
52
|
# inspired by `asyncer`, https://github.com/tiangolo/asyncer
|
38
53
|
def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
|
39
54
|
"""
|
runwayml/_utils/_transform.py
CHANGED
@@ -25,7 +25,7 @@ from ._typing import (
|
|
25
25
|
is_annotated_type,
|
26
26
|
strip_annotated_type,
|
27
27
|
)
|
28
|
-
from .._compat import model_dump, is_typeddict
|
28
|
+
from .._compat import get_origin, model_dump, is_typeddict
|
29
29
|
|
30
30
|
_T = TypeVar("_T")
|
31
31
|
|
@@ -164,9 +164,14 @@ def _transform_recursive(
|
|
164
164
|
inner_type = annotation
|
165
165
|
|
166
166
|
stripped_type = strip_annotated_type(inner_type)
|
167
|
+
origin = get_origin(stripped_type) or stripped_type
|
167
168
|
if is_typeddict(stripped_type) and is_mapping(data):
|
168
169
|
return _transform_typeddict(data, stripped_type)
|
169
170
|
|
171
|
+
if origin == dict and is_mapping(data):
|
172
|
+
items_type = get_args(stripped_type)[1]
|
173
|
+
return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()}
|
174
|
+
|
170
175
|
if (
|
171
176
|
# List[T]
|
172
177
|
(is_list_type(stripped_type) and is_list(data))
|
@@ -307,9 +312,14 @@ async def _async_transform_recursive(
|
|
307
312
|
inner_type = annotation
|
308
313
|
|
309
314
|
stripped_type = strip_annotated_type(inner_type)
|
315
|
+
origin = get_origin(stripped_type) or stripped_type
|
310
316
|
if is_typeddict(stripped_type) and is_mapping(data):
|
311
317
|
return await _async_transform_typeddict(data, stripped_type)
|
312
318
|
|
319
|
+
if origin == dict and is_mapping(data):
|
320
|
+
items_type = get_args(stripped_type)[1]
|
321
|
+
return {key: _transform_recursive(value, annotation=items_type) for key, value in data.items()}
|
322
|
+
|
313
323
|
if (
|
314
324
|
# List[T]
|
315
325
|
(is_list_type(stripped_type) and is_list(data))
|
runwayml/_version.py
CHANGED
@@ -5,21 +5,21 @@ runwayml/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
|
|
5
5
|
runwayml/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
|
6
6
|
runwayml/_exceptions.py,sha256=p2Q8kywHCVQzArLQL4Ht-HetTBhAvevU6yDvEq7PpIE,3224
|
7
7
|
runwayml/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
|
8
|
-
runwayml/_models.py,sha256=
|
8
|
+
runwayml/_models.py,sha256=PDLSNsn3Umxm3UMZPgyBiyN308rRzzPX6F9NO9FU2vs,28943
|
9
9
|
runwayml/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
|
10
10
|
runwayml/_resource.py,sha256=BF-j3xY5eRTKmuTxg8eDhLtLP4MLB1phDh_B6BKipKA,1112
|
11
11
|
runwayml/_response.py,sha256=3Tf7pmDYDMv5BJuF0ljEBtMMk5Q9T7jcWn7I6P-hbdM,28801
|
12
12
|
runwayml/_streaming.py,sha256=NSVuAgknVQWU1cgZEjQn01IdZKKynb5rOeYp5Lo-OEQ,10108
|
13
13
|
runwayml/_types.py,sha256=oHct1QQY_lI8bepCgfWDZm2N5VNi0e6o1iLeiTh4Y_0,6145
|
14
|
-
runwayml/_version.py,sha256=
|
14
|
+
runwayml/_version.py,sha256=ekUU34LiRRIAS3QI35Jod80voCQNRlraSOOkmacoP6Y,160
|
15
15
|
runwayml/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
16
16
|
runwayml/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
|
17
17
|
runwayml/_utils/_logs.py,sha256=ZfS5W59hdqEBVV86lNrk28PhvUxtHOzs9JqiLhSu0pI,780
|
18
18
|
runwayml/_utils/_proxy.py,sha256=z3zsateHtb0EARTWKk8QZNHfPkqJbqwd1lM993LBwGE,1902
|
19
19
|
runwayml/_utils/_reflection.py,sha256=ZmGkIgT_PuwedyNBrrKGbxoWtkpytJNU1uU4QHnmEMU,1364
|
20
20
|
runwayml/_utils/_streams.py,sha256=SMC90diFFecpEg_zgDRVbdR3hSEIgVVij4taD-noMLM,289
|
21
|
-
runwayml/_utils/_sync.py,sha256=
|
22
|
-
runwayml/_utils/_transform.py,sha256=
|
21
|
+
runwayml/_utils/_sync.py,sha256=TpGLrrhRNWTJtODNE6Fup3_k7zrWm1j2RlirzBwre-0,2862
|
22
|
+
runwayml/_utils/_transform.py,sha256=tsSFOIZ7iczaUsMSGBD_iSFOOdUyT2xtkcq1xyF0L9o,13986
|
23
23
|
runwayml/_utils/_typing.py,sha256=nTJz0jcrQbEgxwy4TtAkNxuU0QHHlmc6mQtA6vIR8tg,4501
|
24
24
|
runwayml/_utils/_utils.py,sha256=8UmbPOy_AAr2uUjjFui-VZSrVBHRj6bfNEKRp5YZP2A,12004
|
25
25
|
runwayml/lib/.keep,sha256=wuNrz-5SXo3jJaJOJgz4vFHM41YH_g20F5cRQo0vLes,224
|
@@ -30,7 +30,7 @@ runwayml/types/__init__.py,sha256=R3cLEXzpcEpEOuxaFBo3R72ewH1LtjpkZ0aYOIt1CAo,40
|
|
30
30
|
runwayml/types/image_to_video_create_params.py,sha256=98DsjOHnmHEi8mVjZOQEDL3P1hJUT8uktp0mDA5WJ5Y,1869
|
31
31
|
runwayml/types/image_to_video_create_response.py,sha256=l5GszzUSItV-ZYHCB8hH_GSVibUZEkzfRLrAhXkd8O4,346
|
32
32
|
runwayml/types/task_retrieve_response.py,sha256=v8y2bLxsW6srzScW-B3Akv72q_PI_NQmduGrGRQMHds,2139
|
33
|
-
runwayml-2.2.
|
34
|
-
runwayml-2.2.
|
35
|
-
runwayml-2.2.
|
36
|
-
runwayml-2.2.
|
33
|
+
runwayml-2.2.2.dist-info/METADATA,sha256=rqzi5U4PEg_Lhwk-W-UlQoL0H1WlNs7F11PahFiTO4s,13559
|
34
|
+
runwayml-2.2.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
35
|
+
runwayml-2.2.2.dist-info/licenses/LICENSE,sha256=baeFj6izBWIm6A5_7N3-WAsy_VYpDF05Dd4zS1zsfZI,11338
|
36
|
+
runwayml-2.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|