reflectapi-runtime 0.17.2a4__tar.gz → 0.17.2a5__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.
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/PKG-INFO +1 -1
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/pyproject.toml +1 -1
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/__init__.py +4 -1
- reflectapi_runtime-0.17.2a5/src/reflectapi_runtime/serde.py +48 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/.gitignore +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/README.md +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/auth.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/batch.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/client.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/exceptions.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/hypothesis_strategies.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/middleware.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/option.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/response.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/sse.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/streaming.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/testing.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/transport.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/types.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/__init__.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_auth.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_auth_negative_cases.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_batch.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_client.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_edge_cases.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_enhanced_features.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_exceptions.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_middleware.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_option.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_pydantic_serialization.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_response.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_sse.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_streaming.py +0 -0
- {reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_testing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: reflectapi-runtime
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.2a5
|
|
4
4
|
Summary: Runtime library for ReflectAPI Python clients
|
|
5
5
|
Project-URL: Homepage, https://github.com/thepartly/reflectapi
|
|
6
6
|
Project-URL: Repository, https://github.com/thepartly/reflectapi
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/__init__.py
RENAMED
|
@@ -46,6 +46,7 @@ from .option import (
|
|
|
46
46
|
undefined,
|
|
47
47
|
)
|
|
48
48
|
from .response import ApiResponse, TransportMetadata
|
|
49
|
+
from .serde import parse_externally_tagged, serialize_externally_tagged
|
|
49
50
|
from .streaming import AsyncStreamingClient, StreamingResponse
|
|
50
51
|
from .testing import (
|
|
51
52
|
AsyncCassetteMiddleware,
|
|
@@ -56,7 +57,7 @@ from .testing import (
|
|
|
56
57
|
)
|
|
57
58
|
from .types import BatchResult, ReflectapiEmpty, ReflectapiInfallible
|
|
58
59
|
|
|
59
|
-
__version__ = "0.17.
|
|
60
|
+
__version__ = "0.17.2a5"
|
|
60
61
|
|
|
61
62
|
__all__ = [
|
|
62
63
|
# Authentication
|
|
@@ -97,6 +98,8 @@ __all__ = [
|
|
|
97
98
|
"ReflectapiEmpty",
|
|
98
99
|
"ReflectapiInfallible",
|
|
99
100
|
"ReflectapiOption",
|
|
101
|
+
"parse_externally_tagged",
|
|
102
|
+
"serialize_externally_tagged",
|
|
100
103
|
"StreamingResponse",
|
|
101
104
|
"TestClientMixin",
|
|
102
105
|
"TimeoutError",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Serialization helpers used by generated ReflectAPI clients."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Callable
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
VariantHandler = Callable[[Any], Any] | str
|
|
10
|
+
VariantSerializers = dict[str, tuple[Callable[[Any], bool], Callable[[Any], Any]]]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parse_externally_tagged(
|
|
14
|
+
data: Any,
|
|
15
|
+
variants: dict[str, VariantHandler],
|
|
16
|
+
types: tuple[type[Any], ...],
|
|
17
|
+
enum_name: str,
|
|
18
|
+
) -> Any:
|
|
19
|
+
"""Parse an externally tagged enum from ``{"Variant": value}`` format."""
|
|
20
|
+
if types and isinstance(data, types):
|
|
21
|
+
return data
|
|
22
|
+
if isinstance(data, str) and data in variants:
|
|
23
|
+
handler = variants[data]
|
|
24
|
+
if handler == "_unit":
|
|
25
|
+
return data
|
|
26
|
+
if isinstance(data, dict):
|
|
27
|
+
if len(data) != 1:
|
|
28
|
+
raise ValueError("Externally tagged enum must have exactly one key")
|
|
29
|
+
key, value = next(iter(data.items()))
|
|
30
|
+
if key in variants:
|
|
31
|
+
handler = variants[key]
|
|
32
|
+
if handler == "_unit":
|
|
33
|
+
return key
|
|
34
|
+
if callable(handler):
|
|
35
|
+
return handler(value)
|
|
36
|
+
raise ValueError(f"Unknown variant for {enum_name}: {data}")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def serialize_externally_tagged(
|
|
40
|
+
root: Any,
|
|
41
|
+
serializers: VariantSerializers,
|
|
42
|
+
enum_name: str,
|
|
43
|
+
) -> Any:
|
|
44
|
+
"""Serialize an externally tagged enum to ``{"Variant": value}`` format."""
|
|
45
|
+
for _variant_name, (check, serialize) in serializers.items():
|
|
46
|
+
if check(root):
|
|
47
|
+
return serialize(root)
|
|
48
|
+
raise ValueError(f"Cannot serialize {enum_name} variant: {type(root)}")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/client.py
RENAMED
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/middleware.py
RENAMED
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/option.py
RENAMED
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/response.py
RENAMED
|
File without changes
|
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/streaming.py
RENAMED
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/testing.py
RENAMED
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/src/reflectapi_runtime/transport.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_auth_negative_cases.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{reflectapi_runtime-0.17.2a4 → reflectapi_runtime-0.17.2a5}/tests/test_pydantic_serialization.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|