Skip to content

Commit e9f0dc1

Browse files
release: 0.1.0-alpha.4 (#11)
* chore: rebuild project due to codegen change (#10) * feat(api): update via SDK Studio (#12) * chore(internal): fix compat model_dump method when warnings are passed (#13) * docs: add info log level to readme (#14) * chore: remove now unused `cached-property` dep (#15) * feat(api): update via SDK Studio (#16) * release: 0.1.0-alpha.4 --------- Co-authored-by: stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
1 parent 5ad31f1 commit e9f0dc1

18 files changed

+162
-96
lines changed

.release-please-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.3"
2+
".": "0.1.0-alpha.4"
33
}

.stats.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 5
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prelude%2Fprelude-c1f72f65743e762371400a6f36ba21d4e68ceaa351cb3ea7674cbc04a39e298c.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/prelude%2Fprelude-64c1896dedae5302f4967c8edb2a675a48cba330193a20bdda1409fe3f9f9972.yml

CHANGELOG.md

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
11
# Changelog
22

3+
## 0.1.0-alpha.4 (2024-11-27)
4+
5+
Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/prelude-so/python-sdk/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)
6+
7+
### Features
8+
9+
* **api:** update via SDK Studio ([#12](https://github.com/prelude-so/python-sdk/issues/12)) ([380ea22](https://github.com/prelude-so/python-sdk/commit/380ea22a509deeb05b9b27af7b21aae5a70b4380))
10+
* **api:** update via SDK Studio ([#16](https://github.com/prelude-so/python-sdk/issues/16)) ([a885d0a](https://github.com/prelude-so/python-sdk/commit/a885d0a4aaa978adf582c8743011765dfc65614f))
11+
12+
13+
### Chores
14+
15+
* **internal:** fix compat model_dump method when warnings are passed ([#13](https://github.com/prelude-so/python-sdk/issues/13)) ([7f9b088](https://github.com/prelude-so/python-sdk/commit/7f9b08842698d0eb6911464089583d56db63e0cf))
16+
* rebuild project due to codegen change ([#10](https://github.com/prelude-so/python-sdk/issues/10)) ([afd8c51](https://github.com/prelude-so/python-sdk/commit/afd8c5127bce604ba78290aaf62659a3c02471a5))
17+
* remove now unused `cached-property` dep ([#15](https://github.com/prelude-so/python-sdk/issues/15)) ([292303e](https://github.com/prelude-so/python-sdk/commit/292303e362071f1ba1d7ce2e8311653e4c4ec3f6))
18+
19+
20+
### Documentation
21+
22+
* add info log level to readme ([#14](https://github.com/prelude-so/python-sdk/issues/14)) ([ee4b1b2](https://github.com/prelude-so/python-sdk/commit/ee4b1b2cbfbec80d0ec43cb8e7c54cd0acaad7b9))
23+
324
## 0.1.0-alpha.3 (2024-11-14)
425

526
Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/prelude-so/python-sdk/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,14 @@ Note that requests that time out are [retried twice by default](#retries).
193193

194194
We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.
195195

196-
You can enable logging by setting the environment variable `PRELUDE_LOG` to `debug`.
196+
You can enable logging by setting the environment variable `PRELUDE_LOG` to `info`.
197197

198198
```shell
199-
$ export PRELUDE_LOG=debug
199+
$ export PRELUDE_LOG=info
200200
```
201201

202+
Or to `debug` for more verbose logging.
203+
202204
### How to tell whether `None` means `null` or missing
203205

204206
In an API response, a field may be explicitly `null`, or missing entirely; in either case, its value is `None` in this library. You can differentiate the two cases with `.model_fields_set`:

pyproject.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "prelude-python-sdk"
3-
version = "0.1.0-alpha.3"
3+
version = "0.1.0-alpha.4"
44
description = "The official Python library for the Prelude API"
55
dynamic = ["readme"]
66
license = "Apache-2.0"
@@ -14,7 +14,6 @@ dependencies = [
1414
"anyio>=3.5.0, <5",
1515
"distro>=1.7.0, <2",
1616
"sniffio",
17-
"cached-property; python_version < '3.8'",
1817
]
1918
requires-python = ">= 3.8"
2019
classifiers = [
@@ -55,6 +54,7 @@ dev-dependencies = [
5554
"dirty-equals>=0.6.0",
5655
"importlib-metadata>=6.7.0",
5756
"rich>=13.7.1",
57+
"nest_asyncio==1.6.0"
5858
]
5959

6060
[tool.rye.scripts]

requirements-dev.lock

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ mdurl==0.1.2
5151
mypy==1.13.0
5252
mypy-extensions==1.0.0
5353
# via mypy
54+
nest-asyncio==1.6.0
5455
nodeenv==1.8.0
5556
# via pyright
5657
nox==2023.4.22

src/prelude_python_sdk/_compat.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ def model_dump(
145145
exclude=exclude,
146146
exclude_unset=exclude_unset,
147147
exclude_defaults=exclude_defaults,
148-
warnings=warnings,
148+
# warnings are not supported in Pydantic v1
149+
warnings=warnings if PYDANTIC_V2 else True,
149150
)
150151
return cast(
151152
"dict[str, Any]",
@@ -213,9 +214,6 @@ def __set_name__(self, owner: type[Any], name: str) -> None: ...
213214
# __set__ is not defined at runtime, but @cached_property is designed to be settable
214215
def __set__(self, instance: object, value: _T) -> None: ...
215216
else:
216-
try:
217-
from functools import cached_property as cached_property
218-
except ImportError:
219-
from cached_property import cached_property as cached_property
217+
from functools import cached_property as cached_property
220218

221219
typed_cached_property = cached_property
+40-50
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,62 @@
11
from __future__ import annotations
22

3+
import sys
4+
import asyncio
35
import functools
4-
from typing import TypeVar, Callable, Awaitable
6+
import contextvars
7+
from typing import Any, TypeVar, Callable, Awaitable
58
from typing_extensions import ParamSpec
69

7-
import anyio
8-
import anyio.to_thread
9-
10-
from ._reflection import function_has_argument
11-
1210
T_Retval = TypeVar("T_Retval")
1311
T_ParamSpec = ParamSpec("T_ParamSpec")
1412

1513

16-
# copied from `asyncer`, https://github.com/tiangolo/asyncer
17-
def asyncify(
18-
function: Callable[T_ParamSpec, T_Retval],
19-
*,
20-
cancellable: bool = False,
21-
limiter: anyio.CapacityLimiter | None = None,
22-
) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
14+
if sys.version_info >= (3, 9):
15+
to_thread = asyncio.to_thread
16+
else:
17+
# backport of https://docs.python.org/3/library/asyncio-task.html#asyncio.to_thread
18+
# for Python 3.8 support
19+
async def to_thread(
20+
func: Callable[T_ParamSpec, T_Retval], /, *args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs
21+
) -> Any:
22+
"""Asynchronously run function *func* in a separate thread.
23+
24+
Any *args and **kwargs supplied for this function are directly passed
25+
to *func*. Also, the current :class:`contextvars.Context` is propagated,
26+
allowing context variables from the main thread to be accessed in the
27+
separate thread.
28+
29+
Returns a coroutine that can be awaited to get the eventual result of *func*.
30+
"""
31+
loop = asyncio.events.get_running_loop()
32+
ctx = contextvars.copy_context()
33+
func_call = functools.partial(ctx.run, func, *args, **kwargs)
34+
return await loop.run_in_executor(None, func_call)
35+
36+
37+
# inspired by `asyncer`, https://github.com/tiangolo/asyncer
38+
def asyncify(function: Callable[T_ParamSpec, T_Retval]) -> Callable[T_ParamSpec, Awaitable[T_Retval]]:
2339
"""
2440
Take a blocking function and create an async one that receives the same
25-
positional and keyword arguments, and that when called, calls the original function
26-
in a worker thread using `anyio.to_thread.run_sync()`. Internally,
27-
`asyncer.asyncify()` uses the same `anyio.to_thread.run_sync()`, but it supports
28-
keyword arguments additional to positional arguments and it adds better support for
29-
autocompletion and inline errors for the arguments of the function called and the
30-
return value.
31-
32-
If the `cancellable` option is enabled and the task waiting for its completion is
33-
cancelled, the thread will still run its course but its return value (or any raised
34-
exception) will be ignored.
41+
positional and keyword arguments. For python version 3.9 and above, it uses
42+
asyncio.to_thread to run the function in a separate thread. For python version
43+
3.8, it uses locally defined copy of the asyncio.to_thread function which was
44+
introduced in python 3.9.
3545
36-
Use it like this:
46+
Usage:
3747
38-
```Python
39-
def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
40-
# Do work
41-
return "Some result"
48+
```python
49+
def blocking_func(arg1, arg2, kwarg1=None):
50+
# blocking code
51+
return result
4252
4353
44-
result = await to_thread.asyncify(do_work)("spam", "ham", kwarg1="a", kwarg2="b")
45-
print(result)
54+
result = asyncify(blocking_function)(arg1, arg2, kwarg1=value1)
4655
```
4756
4857
## Arguments
4958
5059
`function`: a blocking regular callable (e.g. a function)
51-
`cancellable`: `True` to allow cancellation of the operation
52-
`limiter`: capacity limiter to use to limit the total amount of threads running
53-
(if omitted, the default limiter is used)
5460
5561
## Return
5662
@@ -60,22 +66,6 @@ def do_work(arg1, arg2, kwarg1="", kwarg2="") -> str:
6066
"""
6167

6268
async def wrapper(*args: T_ParamSpec.args, **kwargs: T_ParamSpec.kwargs) -> T_Retval:
63-
partial_f = functools.partial(function, *args, **kwargs)
64-
65-
# In `v4.1.0` anyio added the `abandon_on_cancel` argument and deprecated the old
66-
# `cancellable` argument, so we need to use the new `abandon_on_cancel` to avoid
67-
# surfacing deprecation warnings.
68-
if function_has_argument(anyio.to_thread.run_sync, "abandon_on_cancel"):
69-
return await anyio.to_thread.run_sync(
70-
partial_f,
71-
abandon_on_cancel=cancellable,
72-
limiter=limiter,
73-
)
74-
75-
return await anyio.to_thread.run_sync(
76-
partial_f,
77-
cancellable=cancellable,
78-
limiter=limiter,
79-
)
69+
return await to_thread(function, *args, **kwargs)
8070

8171
return wrapper

src/prelude_python_sdk/_version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

33
__title__ = "prelude_python_sdk"
4-
__version__ = "0.1.0-alpha.3" # x-release-please-version
4+
__version__ = "0.1.0-alpha.4" # x-release-please-version

src/prelude_python_sdk/types/verification_check_response.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class Metadata(BaseModel):
1313

1414

1515
class VerificationCheckResponse(BaseModel):
16+
status: Literal["success", "failure", "expired_or_not_found"]
17+
"""The status of the check."""
18+
1619
id: Optional[str] = None
1720
"""The verification identifier."""
1821

1922
metadata: Optional[Metadata] = None
2023
"""The metadata for this verification."""
2124

2225
request_id: Optional[str] = None
23-
24-
status: Optional[Literal["success", "failure", "expired"]] = None
25-
"""The status of the check."""

src/prelude_python_sdk/types/verification_create_params.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ class Options(TypedDict, total=False):
4646
devices.
4747
"""
4848

49+
custom_code: str
50+
"""The custom code to use for OTP verification.
51+
52+
This feature is only available for compatibility purposes and subject to
53+
Prelude’s approval. Contact us to discuss your use case.
54+
"""
55+
4956
locale: str
5057
"""
5158
A BCP-47 formatted locale string with the language the text message will be sent
@@ -82,7 +89,7 @@ class Signals(TypedDict, total=False):
8289
device_model: str
8390
"""The model of the user's device."""
8491

85-
device_platform: Literal["android", "ios", "web"]
92+
device_platform: Literal["android", "ios", "ipados", "tvos", "web"]
8693
"""The type of the user's device."""
8794

8895
ip: str

src/prelude_python_sdk/types/verification_create_response.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ class Metadata(BaseModel):
1313

1414

1515
class VerificationCreateResponse(BaseModel):
16-
id: Optional[str] = None
16+
id: str
1717
"""The verification identifier."""
1818

19+
method: Literal["message"]
20+
"""The method used for verifying this phone number."""
21+
22+
status: Literal["success", "retry", "blocked"]
23+
"""The status of the verification."""
24+
1925
metadata: Optional[Metadata] = None
2026
"""The metadata for this verification."""
2127

22-
method: Optional[Literal["message"]] = None
23-
"""The method used for verifying this phone number."""
24-
2528
request_id: Optional[str] = None
26-
27-
status: Optional[Literal["success", "retry", "blocked"]] = None
28-
"""The status of the verification."""
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Optional
43

54
from .._models import BaseModel
65

76
__all__ = ["WatchFeedBackResponse"]
87

98

109
class WatchFeedBackResponse(BaseModel):
11-
id: Optional[str] = None
10+
id: str
1211
"""A unique identifier for your feedback request."""

src/prelude_python_sdk/types/watch_predict_response.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class Reasoning(BaseModel):
2020

2121

2222
class WatchPredictResponse(BaseModel):
23-
id: Optional[str] = None
23+
id: str
2424
"""A unique identifier for your prediction request."""
2525

26-
prediction: Optional[Literal["allow", "block"]] = None
26+
prediction: Literal["allow", "block"]
2727
"""A label indicating the trustworthiness of the phone number."""
2828

29-
reasoning: Optional[Reasoning] = None
29+
reasoning: Reasoning

0 commit comments

Comments
 (0)