runwayml 2.1.4__tar.gz → 2.1.6__tar.gz
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-2.1.6/.release-please-manifest.json +3 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/CHANGELOG.md +29 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/PKG-INFO +15 -4
- {runwayml-2.1.4 → runwayml-2.1.6}/README.md +10 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/pyproject.toml +2 -2
- {runwayml-2.1.4 → runwayml-2.1.6}/requirements-dev.lock +1 -1
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_client.py +18 -18
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_models.py +3 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_response.py +10 -10
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/__init__.py +1 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_typing.py +30 -1
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_version.py +1 -1
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_client.py +4 -4
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_models.py +17 -1
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/utils.py +4 -0
- runwayml-2.1.4/.release-please-manifest.json +0 -3
- {runwayml-2.1.4 → runwayml-2.1.6}/.gitignore +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/CONTRIBUTING.md +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/LICENSE +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/SECURITY.md +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/api.md +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/bin/check-release-environment +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/bin/publish-pypi +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/examples/.keep +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/mypy.ini +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/noxfile.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/release-please-config.json +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/requirements.lock +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/__init__.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_base_client.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_compat.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_constants.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_exceptions.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_files.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_qs.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_resource.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_streaming.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_types.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_logs.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_proxy.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_reflection.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_streams.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_sync.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_transform.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/_utils/_utils.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/lib/.keep +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/py.typed +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/resources/__init__.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/resources/image_to_video.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/resources/tasks.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/types/__init__.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/types/image_to_video_create_params.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/types/image_to_video_create_response.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/src/runwayml/types/task_retrieve_response.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/__init__.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/api_resources/__init__.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/api_resources/test_image_to_video.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/api_resources/test_tasks.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/conftest.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/sample_file.txt +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_deepcopy.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_extract_files.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_files.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_qs.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_required_args.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_response.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_streaming.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_transform.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_utils/test_proxy.py +0 -0
- {runwayml-2.1.4 → runwayml-2.1.6}/tests/test_utils/test_typing.py +0 -0
@@ -1,5 +1,34 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 2.1.6 (2024-12-18)
|
4
|
+
|
5
|
+
Full Changelog: [v2.1.5...v2.1.6](https://github.com/runwayml/sdk-python/compare/v2.1.5...v2.1.6)
|
6
|
+
|
7
|
+
### Chores
|
8
|
+
|
9
|
+
* **internal:** codegen related update ([#48](https://github.com/runwayml/sdk-python/issues/48)) ([f999274](https://github.com/runwayml/sdk-python/commit/f999274cbc241f063e3f6abdd7bef93749066c05))
|
10
|
+
* **internal:** codegen related update ([#50](https://github.com/runwayml/sdk-python/issues/50)) ([187e174](https://github.com/runwayml/sdk-python/commit/187e1747d62dc99718de5d2dfb5bc8fa8291ab34))
|
11
|
+
* **internal:** codegen related update ([#51](https://github.com/runwayml/sdk-python/issues/51)) ([1c70164](https://github.com/runwayml/sdk-python/commit/1c701642c7797d49ce59bc938b0f18511f3c6d9e))
|
12
|
+
* **internal:** codegen related update ([#52](https://github.com/runwayml/sdk-python/issues/52)) ([07e7dda](https://github.com/runwayml/sdk-python/commit/07e7ddaae96eb26063a88e6bc23adef2f9b0e7d5))
|
13
|
+
* **internal:** codegen related update ([#54](https://github.com/runwayml/sdk-python/issues/54)) ([5540248](https://github.com/runwayml/sdk-python/commit/55402489160f4cb43244f90e5f85c90bd96a7729))
|
14
|
+
* **internal:** codegen related update ([#55](https://github.com/runwayml/sdk-python/issues/55)) ([75daba1](https://github.com/runwayml/sdk-python/commit/75daba1936f201824daec2b8b08abf68a52b55d7))
|
15
|
+
* **internal:** codegen related update ([#56](https://github.com/runwayml/sdk-python/issues/56)) ([c98ed80](https://github.com/runwayml/sdk-python/commit/c98ed80958344be95507a3c5ef7ede3006cf6bf5))
|
16
|
+
* **internal:** fix some typos ([#58](https://github.com/runwayml/sdk-python/issues/58)) ([404c771](https://github.com/runwayml/sdk-python/commit/404c771242c581f9c618966a03b5de5f5db8a5da))
|
17
|
+
|
18
|
+
|
19
|
+
### Documentation
|
20
|
+
|
21
|
+
* **readme:** example snippet for client context manager ([#57](https://github.com/runwayml/sdk-python/issues/57)) ([e62b5e9](https://github.com/runwayml/sdk-python/commit/e62b5e9d1176d72c7285ede6200436bc994260ae))
|
22
|
+
|
23
|
+
## 2.1.5 (2024-12-13)
|
24
|
+
|
25
|
+
Full Changelog: [v2.1.4...v2.1.5](https://github.com/runwayml/sdk-python/compare/v2.1.4...v2.1.5)
|
26
|
+
|
27
|
+
### Chores
|
28
|
+
|
29
|
+
* **internal:** add support for TypeAliasType ([#46](https://github.com/runwayml/sdk-python/issues/46)) ([278afad](https://github.com/runwayml/sdk-python/commit/278afade7c0541db8a14f4dbb763ec6cd2797558))
|
30
|
+
* **internal:** bump pyright ([#44](https://github.com/runwayml/sdk-python/issues/44)) ([eb51ffa](https://github.com/runwayml/sdk-python/commit/eb51ffa9ef89567501d19cf9183ac64792062559))
|
31
|
+
|
3
32
|
## 2.1.4 (2024-12-10)
|
4
33
|
|
5
34
|
Full Changelog: [v2.1.3...v2.1.4](https://github.com/runwayml/sdk-python/compare/v2.1.3...v2.1.4)
|
@@ -1,11 +1,12 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: runwayml
|
3
|
-
Version: 2.1.
|
3
|
+
Version: 2.1.6
|
4
4
|
Summary: The official Python library for the runwayml API
|
5
5
|
Project-URL: Homepage, https://github.com/runwayml/sdk-python
|
6
6
|
Project-URL: Repository, https://github.com/runwayml/sdk-python
|
7
7
|
Author-email: RunwayML <dev-feedback@runwayml.com>
|
8
|
-
License: Apache-2.0
|
8
|
+
License-Expression: Apache-2.0
|
9
|
+
License-File: LICENSE
|
9
10
|
Classifier: Intended Audience :: Developers
|
10
11
|
Classifier: License :: OSI Approved :: Apache Software License
|
11
12
|
Classifier: Operating System :: MacOS
|
@@ -26,7 +27,7 @@ Requires-Dist: distro<2,>=1.7.0
|
|
26
27
|
Requires-Dist: httpx<1,>=0.23.0
|
27
28
|
Requires-Dist: pydantic<3,>=1.9.0
|
28
29
|
Requires-Dist: sniffio
|
29
|
-
Requires-Dist: typing-extensions<5,>=4.
|
30
|
+
Requires-Dist: typing-extensions<5,>=4.10
|
30
31
|
Description-Content-Type: text/markdown
|
31
32
|
|
32
33
|
# RunwayML Python API library
|
@@ -349,6 +350,16 @@ client.with_options(http_client=DefaultHttpxClient(...))
|
|
349
350
|
|
350
351
|
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
|
351
352
|
|
353
|
+
```py
|
354
|
+
from runwayml import RunwayML
|
355
|
+
|
356
|
+
with RunwayML() as client:
|
357
|
+
# make requests here
|
358
|
+
...
|
359
|
+
|
360
|
+
# HTTP client is now closed
|
361
|
+
```
|
362
|
+
|
352
363
|
## Versioning
|
353
364
|
|
354
365
|
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
@@ -318,6 +318,16 @@ client.with_options(http_client=DefaultHttpxClient(...))
|
|
318
318
|
|
319
319
|
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.
|
320
320
|
|
321
|
+
```py
|
322
|
+
from runwayml import RunwayML
|
323
|
+
|
324
|
+
with RunwayML() as client:
|
325
|
+
# make requests here
|
326
|
+
...
|
327
|
+
|
328
|
+
# HTTP client is now closed
|
329
|
+
```
|
330
|
+
|
321
331
|
## Versioning
|
322
332
|
|
323
333
|
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "runwayml"
|
3
|
-
version = "2.1.
|
3
|
+
version = "2.1.6"
|
4
4
|
description = "The official Python library for the runwayml API"
|
5
5
|
dynamic = ["readme"]
|
6
6
|
license = "Apache-2.0"
|
@@ -10,7 +10,7 @@ authors = [
|
|
10
10
|
dependencies = [
|
11
11
|
"httpx>=0.23.0, <1",
|
12
12
|
"pydantic>=1.9.0, <3",
|
13
|
-
"typing-extensions>=4.
|
13
|
+
"typing-extensions>=4.10, <5",
|
14
14
|
"anyio>=3.5.0, <5",
|
15
15
|
"distro>=1.7.0, <2",
|
16
16
|
"sniffio",
|
@@ -8,7 +8,7 @@ from typing_extensions import Self, override
|
|
8
8
|
|
9
9
|
import httpx
|
10
10
|
|
11
|
-
from . import
|
11
|
+
from . import _exceptions
|
12
12
|
from ._qs import Querystring
|
13
13
|
from ._types import (
|
14
14
|
NOT_GIVEN,
|
@@ -24,6 +24,7 @@ from ._utils import (
|
|
24
24
|
get_async_library,
|
25
25
|
)
|
26
26
|
from ._version import __version__
|
27
|
+
from .resources import tasks, image_to_video
|
27
28
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
28
29
|
from ._exceptions import RunwayMLError, APIStatusError
|
29
30
|
from ._base_client import (
|
@@ -37,7 +38,6 @@ __all__ = [
|
|
37
38
|
"Transport",
|
38
39
|
"ProxiesTypes",
|
39
40
|
"RequestOptions",
|
40
|
-
"resources",
|
41
41
|
"RunwayML",
|
42
42
|
"AsyncRunwayML",
|
43
43
|
"Client",
|
@@ -46,8 +46,8 @@ __all__ = [
|
|
46
46
|
|
47
47
|
|
48
48
|
class RunwayML(SyncAPIClient):
|
49
|
-
tasks:
|
50
|
-
image_to_video:
|
49
|
+
tasks: tasks.TasksResource
|
50
|
+
image_to_video: image_to_video.ImageToVideoResource
|
51
51
|
with_raw_response: RunwayMLWithRawResponse
|
52
52
|
with_streaming_response: RunwayMLWithStreamedResponse
|
53
53
|
|
@@ -111,8 +111,8 @@ class RunwayML(SyncAPIClient):
|
|
111
111
|
_strict_response_validation=_strict_response_validation,
|
112
112
|
)
|
113
113
|
|
114
|
-
self.tasks =
|
115
|
-
self.image_to_video =
|
114
|
+
self.tasks = tasks.TasksResource(self)
|
115
|
+
self.image_to_video = image_to_video.ImageToVideoResource(self)
|
116
116
|
self.with_raw_response = RunwayMLWithRawResponse(self)
|
117
117
|
self.with_streaming_response = RunwayMLWithStreamedResponse(self)
|
118
118
|
|
@@ -225,8 +225,8 @@ class RunwayML(SyncAPIClient):
|
|
225
225
|
|
226
226
|
|
227
227
|
class AsyncRunwayML(AsyncAPIClient):
|
228
|
-
tasks:
|
229
|
-
image_to_video:
|
228
|
+
tasks: tasks.AsyncTasksResource
|
229
|
+
image_to_video: image_to_video.AsyncImageToVideoResource
|
230
230
|
with_raw_response: AsyncRunwayMLWithRawResponse
|
231
231
|
with_streaming_response: AsyncRunwayMLWithStreamedResponse
|
232
232
|
|
@@ -290,8 +290,8 @@ class AsyncRunwayML(AsyncAPIClient):
|
|
290
290
|
_strict_response_validation=_strict_response_validation,
|
291
291
|
)
|
292
292
|
|
293
|
-
self.tasks =
|
294
|
-
self.image_to_video =
|
293
|
+
self.tasks = tasks.AsyncTasksResource(self)
|
294
|
+
self.image_to_video = image_to_video.AsyncImageToVideoResource(self)
|
295
295
|
self.with_raw_response = AsyncRunwayMLWithRawResponse(self)
|
296
296
|
self.with_streaming_response = AsyncRunwayMLWithStreamedResponse(self)
|
297
297
|
|
@@ -405,26 +405,26 @@ class AsyncRunwayML(AsyncAPIClient):
|
|
405
405
|
|
406
406
|
class RunwayMLWithRawResponse:
|
407
407
|
def __init__(self, client: RunwayML) -> None:
|
408
|
-
self.tasks =
|
409
|
-
self.image_to_video =
|
408
|
+
self.tasks = tasks.TasksResourceWithRawResponse(client.tasks)
|
409
|
+
self.image_to_video = image_to_video.ImageToVideoResourceWithRawResponse(client.image_to_video)
|
410
410
|
|
411
411
|
|
412
412
|
class AsyncRunwayMLWithRawResponse:
|
413
413
|
def __init__(self, client: AsyncRunwayML) -> None:
|
414
|
-
self.tasks =
|
415
|
-
self.image_to_video =
|
414
|
+
self.tasks = tasks.AsyncTasksResourceWithRawResponse(client.tasks)
|
415
|
+
self.image_to_video = image_to_video.AsyncImageToVideoResourceWithRawResponse(client.image_to_video)
|
416
416
|
|
417
417
|
|
418
418
|
class RunwayMLWithStreamedResponse:
|
419
419
|
def __init__(self, client: RunwayML) -> None:
|
420
|
-
self.tasks =
|
421
|
-
self.image_to_video =
|
420
|
+
self.tasks = tasks.TasksResourceWithStreamingResponse(client.tasks)
|
421
|
+
self.image_to_video = image_to_video.ImageToVideoResourceWithStreamingResponse(client.image_to_video)
|
422
422
|
|
423
423
|
|
424
424
|
class AsyncRunwayMLWithStreamedResponse:
|
425
425
|
def __init__(self, client: AsyncRunwayML) -> None:
|
426
|
-
self.tasks =
|
427
|
-
self.image_to_video =
|
426
|
+
self.tasks = tasks.AsyncTasksResourceWithStreamingResponse(client.tasks)
|
427
|
+
self.image_to_video = image_to_video.AsyncImageToVideoResourceWithStreamingResponse(client.image_to_video)
|
428
428
|
|
429
429
|
|
430
430
|
Client = RunwayML
|
@@ -46,6 +46,7 @@ from ._utils import (
|
|
46
46
|
strip_not_given,
|
47
47
|
extract_type_arg,
|
48
48
|
is_annotated_type,
|
49
|
+
is_type_alias_type,
|
49
50
|
strip_annotated_type,
|
50
51
|
)
|
51
52
|
from ._compat import (
|
@@ -428,6 +429,8 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
428
429
|
# we allow `object` as the input type because otherwise, passing things like
|
429
430
|
# `Literal['value']` will be reported as a type error by type checkers
|
430
431
|
type_ = cast("type[object]", type_)
|
432
|
+
if is_type_alias_type(type_):
|
433
|
+
type_ = type_.__value__ # type: ignore[unreachable]
|
431
434
|
|
432
435
|
# unwrap `Annotated[T, ...]` -> `T`
|
433
436
|
if is_annotated_type(type_):
|
@@ -25,7 +25,7 @@ import httpx
|
|
25
25
|
import pydantic
|
26
26
|
|
27
27
|
from ._types import NoneType
|
28
|
-
from ._utils import is_given, extract_type_arg, is_annotated_type, extract_type_var_from_base
|
28
|
+
from ._utils import is_given, extract_type_arg, is_annotated_type, is_type_alias_type, extract_type_var_from_base
|
29
29
|
from ._models import BaseModel, is_basemodel
|
30
30
|
from ._constants import RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER
|
31
31
|
from ._streaming import Stream, AsyncStream, is_stream_class_type, extract_stream_chunk_type
|
@@ -126,9 +126,15 @@ class BaseAPIResponse(Generic[R]):
|
|
126
126
|
)
|
127
127
|
|
128
128
|
def _parse(self, *, to: type[_T] | None = None) -> R | _T:
|
129
|
+
cast_to = to if to is not None else self._cast_to
|
130
|
+
|
131
|
+
# unwrap `TypeAlias('Name', T)` -> `T`
|
132
|
+
if is_type_alias_type(cast_to):
|
133
|
+
cast_to = cast_to.__value__ # type: ignore[unreachable]
|
134
|
+
|
129
135
|
# unwrap `Annotated[T, ...]` -> `T`
|
130
|
-
if
|
131
|
-
|
136
|
+
if cast_to and is_annotated_type(cast_to):
|
137
|
+
cast_to = extract_type_arg(cast_to, 0)
|
132
138
|
|
133
139
|
if self._is_sse_stream:
|
134
140
|
if to:
|
@@ -164,18 +170,12 @@ class BaseAPIResponse(Generic[R]):
|
|
164
170
|
return cast(
|
165
171
|
R,
|
166
172
|
stream_cls(
|
167
|
-
cast_to=
|
173
|
+
cast_to=cast_to,
|
168
174
|
response=self.http_response,
|
169
175
|
client=cast(Any, self._client),
|
170
176
|
),
|
171
177
|
)
|
172
178
|
|
173
|
-
cast_to = to if to is not None else self._cast_to
|
174
|
-
|
175
|
-
# unwrap `Annotated[T, ...]` -> `T`
|
176
|
-
if is_annotated_type(cast_to):
|
177
|
-
cast_to = extract_type_arg(cast_to, 0)
|
178
|
-
|
179
179
|
if cast_to is NoneType:
|
180
180
|
return cast(R, None)
|
181
181
|
|
@@ -39,6 +39,7 @@ from ._typing import (
|
|
39
39
|
is_iterable_type as is_iterable_type,
|
40
40
|
is_required_type as is_required_type,
|
41
41
|
is_annotated_type as is_annotated_type,
|
42
|
+
is_type_alias_type as is_type_alias_type,
|
42
43
|
strip_annotated_type as strip_annotated_type,
|
43
44
|
extract_type_var_from_base as extract_type_var_from_base,
|
44
45
|
)
|
@@ -1,8 +1,17 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
|
+
import sys
|
4
|
+
import typing
|
5
|
+
import typing_extensions
|
3
6
|
from typing import Any, TypeVar, Iterable, cast
|
4
7
|
from collections import abc as _c_abc
|
5
|
-
from typing_extensions import
|
8
|
+
from typing_extensions import (
|
9
|
+
TypeIs,
|
10
|
+
Required,
|
11
|
+
Annotated,
|
12
|
+
get_args,
|
13
|
+
get_origin,
|
14
|
+
)
|
6
15
|
|
7
16
|
from .._types import InheritsGeneric
|
8
17
|
from .._compat import is_union as _is_union
|
@@ -36,6 +45,26 @@ def is_typevar(typ: type) -> bool:
|
|
36
45
|
return type(typ) == TypeVar # type: ignore
|
37
46
|
|
38
47
|
|
48
|
+
_TYPE_ALIAS_TYPES: tuple[type[typing_extensions.TypeAliasType], ...] = (typing_extensions.TypeAliasType,)
|
49
|
+
if sys.version_info >= (3, 12):
|
50
|
+
_TYPE_ALIAS_TYPES = (*_TYPE_ALIAS_TYPES, typing.TypeAliasType)
|
51
|
+
|
52
|
+
|
53
|
+
def is_type_alias_type(tp: Any, /) -> TypeIs[typing_extensions.TypeAliasType]:
|
54
|
+
"""Return whether the provided argument is an instance of `TypeAliasType`.
|
55
|
+
|
56
|
+
```python
|
57
|
+
type Int = int
|
58
|
+
is_type_alias_type(Int)
|
59
|
+
# > True
|
60
|
+
Str = TypeAliasType("Str", str)
|
61
|
+
is_type_alias_type(Str)
|
62
|
+
# > True
|
63
|
+
```
|
64
|
+
"""
|
65
|
+
return isinstance(tp, _TYPE_ALIAS_TYPES)
|
66
|
+
|
67
|
+
|
39
68
|
# Extracts T from Annotated[T, ...] or from Required[Annotated[T, ...]]
|
40
69
|
def strip_annotated_type(typ: type) -> type:
|
41
70
|
if is_required_type(typ) or is_annotated_type(typ):
|
@@ -355,11 +355,11 @@ class TestRunwayML:
|
|
355
355
|
FinalRequestOptions(
|
356
356
|
method="get",
|
357
357
|
url="/foo",
|
358
|
-
params={"foo": "baz", "query_param": "
|
358
|
+
params={"foo": "baz", "query_param": "overridden"},
|
359
359
|
)
|
360
360
|
)
|
361
361
|
url = httpx.URL(request.url)
|
362
|
-
assert dict(url.params) == {"foo": "baz", "query_param": "
|
362
|
+
assert dict(url.params) == {"foo": "baz", "query_param": "overridden"}
|
363
363
|
|
364
364
|
def test_request_extra_json(self) -> None:
|
365
365
|
request = self.client._build_request(
|
@@ -1137,11 +1137,11 @@ class TestAsyncRunwayML:
|
|
1137
1137
|
FinalRequestOptions(
|
1138
1138
|
method="get",
|
1139
1139
|
url="/foo",
|
1140
|
-
params={"foo": "baz", "query_param": "
|
1140
|
+
params={"foo": "baz", "query_param": "overridden"},
|
1141
1141
|
)
|
1142
1142
|
)
|
1143
1143
|
url = httpx.URL(request.url)
|
1144
|
-
assert dict(url.params) == {"foo": "baz", "query_param": "
|
1144
|
+
assert dict(url.params) == {"foo": "baz", "query_param": "overridden"}
|
1145
1145
|
|
1146
1146
|
def test_request_extra_json(self) -> None:
|
1147
1147
|
request = self.client._build_request(
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import json
|
2
2
|
from typing import Any, Dict, List, Union, Optional, cast
|
3
3
|
from datetime import datetime, timezone
|
4
|
-
from typing_extensions import Literal, Annotated
|
4
|
+
from typing_extensions import Literal, Annotated, TypeAliasType
|
5
5
|
|
6
6
|
import pytest
|
7
7
|
import pydantic
|
@@ -828,3 +828,19 @@ def test_discriminated_unions_invalid_data_uses_cache() -> None:
|
|
828
828
|
# if the discriminator details object stays the same between invocations then
|
829
829
|
# we hit the cache
|
830
830
|
assert UnionType.__discriminator__ is discriminator
|
831
|
+
|
832
|
+
|
833
|
+
@pytest.mark.skipif(not PYDANTIC_V2, reason="TypeAliasType is not supported in Pydantic v1")
|
834
|
+
def test_type_alias_type() -> None:
|
835
|
+
Alias = TypeAliasType("Alias", str)
|
836
|
+
|
837
|
+
class Model(BaseModel):
|
838
|
+
alias: Alias
|
839
|
+
union: Union[int, Alias]
|
840
|
+
|
841
|
+
m = construct_type(value={"alias": "foo", "union": "bar"}, type_=Model)
|
842
|
+
assert isinstance(m, Model)
|
843
|
+
assert isinstance(m.alias, str)
|
844
|
+
assert m.alias == "foo"
|
845
|
+
assert isinstance(m.union, str)
|
846
|
+
assert m.union == "bar"
|
@@ -16,6 +16,7 @@ from runwayml._utils import (
|
|
16
16
|
is_union_type,
|
17
17
|
extract_type_arg,
|
18
18
|
is_annotated_type,
|
19
|
+
is_type_alias_type,
|
19
20
|
)
|
20
21
|
from runwayml._compat import PYDANTIC_V2, field_outer_type, get_model_fields
|
21
22
|
from runwayml._models import BaseModel
|
@@ -51,6 +52,9 @@ def assert_matches_type(
|
|
51
52
|
path: list[str],
|
52
53
|
allow_none: bool = False,
|
53
54
|
) -> None:
|
55
|
+
if is_type_alias_type(type_):
|
56
|
+
type_ = type_.__value__
|
57
|
+
|
54
58
|
# unwrap `Annotated[T, ...]` -> `T`
|
55
59
|
if is_annotated_type(type_):
|
56
60
|
type_ = extract_type_arg(type_, 0)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|