prelude-python-sdk 0.1.0a5__tar.gz → 0.1.0a7__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.
- prelude_python_sdk-0.1.0a7/.release-please-manifest.json +3 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/CHANGELOG.md +49 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/LICENSE +1 -1
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/PKG-INFO +22 -11
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/README.md +17 -7
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/pyproject.toml +3 -3
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/requirements-dev.lock +5 -6
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/requirements.lock +3 -4
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/__init__.py +2 -1
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_base_client.py +6 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_client.py +27 -36
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_models.py +8 -1
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_response.py +10 -10
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_types.py +2 -4
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/__init__.py +1 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_typing.py +30 -1
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_version.py +1 -1
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/verification_create_params.py +23 -6
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/api_resources/test_verification.py +12 -4
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_client.py +4 -4
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_models.py +17 -1
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/utils.py +4 -0
- prelude_python_sdk-0.1.0a5/.release-please-manifest.json +0 -3
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/.gitignore +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/CONTRIBUTING.md +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/SECURITY.md +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/api.md +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/bin/check-release-environment +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/bin/publish-pypi +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/examples/.keep +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/mypy.ini +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/noxfile.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/release-please-config.json +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude/lib/.keep +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_compat.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_constants.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_exceptions.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_files.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_qs.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_resource.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_streaming.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_logs.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_proxy.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_reflection.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_streams.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_sync.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_transform.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_utils.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/lib/.keep +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/py.typed +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/resources/__init__.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/resources/transactional.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/resources/verification.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/resources/watch.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/__init__.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/transactional_send_params.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/transactional_send_response.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/verification_check_params.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/verification_check_response.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/verification_create_response.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/watch_feed_back_params.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/watch_feed_back_response.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/watch_predict_params.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/watch_predict_response.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_sdk/lib/.keep +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/__init__.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/api_resources/__init__.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/api_resources/test_transactional.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/api_resources/test_watch.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/conftest.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/sample_file.txt +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_deepcopy.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_extract_files.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_files.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_qs.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_required_args.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_response.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_streaming.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_transform.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_utils/test_proxy.py +0 -0
- {prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/test_utils/test_typing.py +0 -0
|
@@ -1,5 +1,54 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.0-alpha.7 (2025-01-08)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v0.1.0-alpha.6...v0.1.0-alpha.7](https://github.com/prelude-so/python-sdk/compare/v0.1.0-alpha.6...v0.1.0-alpha.7)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **api:** update via SDK Studio ([#40](https://github.com/prelude-so/python-sdk/issues/40)) ([a16ad08](https://github.com/prelude-so/python-sdk/commit/a16ad08cc54132be9f0d3553b21d98ca983edcba))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **client:** only call .close() when needed ([#37](https://github.com/prelude-so/python-sdk/issues/37)) ([9d64934](https://github.com/prelude-so/python-sdk/commit/9d64934403b4cfa4becd15b3d4f9934354ce1135))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Chores
|
|
18
|
+
|
|
19
|
+
* add missing isclass check ([#35](https://github.com/prelude-so/python-sdk/issues/35)) ([09b83f5](https://github.com/prelude-so/python-sdk/commit/09b83f50fd71367bee93758a31cd53621ba56ab3))
|
|
20
|
+
* **internal:** add support for TypeAliasType ([#31](https://github.com/prelude-so/python-sdk/issues/31)) ([a734093](https://github.com/prelude-so/python-sdk/commit/a7340937bba33d659b17e001c3dc98d7f4b8d009))
|
|
21
|
+
* **internal:** bump httpx dependency ([#36](https://github.com/prelude-so/python-sdk/issues/36)) ([39a4778](https://github.com/prelude-so/python-sdk/commit/39a4778690edc67b96e4b7a67e8d75b3d184502a))
|
|
22
|
+
* **internal:** bump pyright ([#29](https://github.com/prelude-so/python-sdk/issues/29)) ([d10ba94](https://github.com/prelude-so/python-sdk/commit/d10ba94c17a48a69d6de2551f91d417dfd1a14e2))
|
|
23
|
+
* **internal:** codegen related update ([#32](https://github.com/prelude-so/python-sdk/issues/32)) ([f68da06](https://github.com/prelude-so/python-sdk/commit/f68da06af9e1db5524256ee91adeb46746e2d9ce))
|
|
24
|
+
* **internal:** codegen related update ([#34](https://github.com/prelude-so/python-sdk/issues/34)) ([9ac58c5](https://github.com/prelude-so/python-sdk/commit/9ac58c502a1247208c6bc77d482f87b6389dd1a9))
|
|
25
|
+
* **internal:** codegen related update ([#39](https://github.com/prelude-so/python-sdk/issues/39)) ([655d237](https://github.com/prelude-so/python-sdk/commit/655d237f79cf048671378fdfa340b9c32cc36484))
|
|
26
|
+
* **internal:** fix some typos ([#33](https://github.com/prelude-so/python-sdk/issues/33)) ([f720959](https://github.com/prelude-so/python-sdk/commit/f72095954c5f648759c52261916944c4363f2614))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Documentation
|
|
30
|
+
|
|
31
|
+
* fix typos ([#38](https://github.com/prelude-so/python-sdk/issues/38)) ([84b1be6](https://github.com/prelude-so/python-sdk/commit/84b1be6c4450fbed3d9436dc48ad22a10ec75e0d))
|
|
32
|
+
|
|
33
|
+
## 0.1.0-alpha.6 (2024-12-11)
|
|
34
|
+
|
|
35
|
+
Full Changelog: [v0.1.0-alpha.5...v0.1.0-alpha.6](https://github.com/prelude-so/python-sdk/compare/v0.1.0-alpha.5...v0.1.0-alpha.6)
|
|
36
|
+
|
|
37
|
+
### Features
|
|
38
|
+
|
|
39
|
+
* **api:** update via SDK Studio ([#27](https://github.com/prelude-so/python-sdk/issues/27)) ([e34eb1c](https://github.com/prelude-so/python-sdk/commit/e34eb1c2f450d5068cce21d414d3a4a04c3b0766))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Chores
|
|
43
|
+
|
|
44
|
+
* **internal:** bump pydantic dependency ([#25](https://github.com/prelude-so/python-sdk/issues/25)) ([62168ae](https://github.com/prelude-so/python-sdk/commit/62168aeb00400db101ef33e54b8c3d8446bea8f4))
|
|
45
|
+
* make the `Omit` type public ([#23](https://github.com/prelude-so/python-sdk/issues/23)) ([b8aa425](https://github.com/prelude-so/python-sdk/commit/b8aa425a77c73290a46dba106cb7277e67d1bf0f))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Documentation
|
|
49
|
+
|
|
50
|
+
* **readme:** fix http client proxies example ([#26](https://github.com/prelude-so/python-sdk/issues/26)) ([66ce358](https://github.com/prelude-so/python-sdk/commit/66ce358d153fef76d64827abe99907badb64d220))
|
|
51
|
+
|
|
3
52
|
## 0.1.0-alpha.5 (2024-12-03)
|
|
4
53
|
|
|
5
54
|
Full Changelog: [v0.1.0-alpha.4...v0.1.0-alpha.5](https://github.com/prelude-so/python-sdk/compare/v0.1.0-alpha.4...v0.1.0-alpha.5)
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2025 Prelude
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: prelude-python-sdk
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.0a7
|
|
4
4
|
Summary: The official Python library for the Prelude API
|
|
5
5
|
Project-URL: Homepage, https://github.com/prelude-so/python-sdk
|
|
6
6
|
Project-URL: Repository, https://github.com/prelude-so/python-sdk
|
|
7
7
|
Author-email: Prelude <hello@prelude.so>
|
|
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
|
# Prelude Python API library
|
|
@@ -147,7 +148,7 @@ except prelude_python_sdk.APIStatusError as e:
|
|
|
147
148
|
print(e.response)
|
|
148
149
|
```
|
|
149
150
|
|
|
150
|
-
Error codes are as
|
|
151
|
+
Error codes are as follows:
|
|
151
152
|
|
|
152
153
|
| Status Code | Error Type |
|
|
153
154
|
| ----------- | -------------------------- |
|
|
@@ -298,8 +299,7 @@ If you need to access undocumented endpoints, params, or response properties, th
|
|
|
298
299
|
#### Undocumented endpoints
|
|
299
300
|
|
|
300
301
|
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
|
|
301
|
-
http verbs. Options on the client will be respected (such as retries)
|
|
302
|
-
request.
|
|
302
|
+
http verbs. Options on the client will be respected (such as retries) when making this request.
|
|
303
303
|
|
|
304
304
|
```py
|
|
305
305
|
import httpx
|
|
@@ -328,18 +328,19 @@ can also get all the extra fields on the Pydantic model as a dict with
|
|
|
328
328
|
|
|
329
329
|
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
|
|
330
330
|
|
|
331
|
-
- Support for proxies
|
|
332
|
-
- Custom transports
|
|
331
|
+
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
|
|
332
|
+
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
|
|
333
333
|
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality
|
|
334
334
|
|
|
335
335
|
```python
|
|
336
|
+
import httpx
|
|
336
337
|
from prelude_python_sdk import Prelude, DefaultHttpxClient
|
|
337
338
|
|
|
338
339
|
client = Prelude(
|
|
339
340
|
# Or use the `PRELUDE_BASE_URL` env var
|
|
340
341
|
base_url="http://my.test.server.example.com:8083",
|
|
341
342
|
http_client=DefaultHttpxClient(
|
|
342
|
-
|
|
343
|
+
proxy="http://my.test.proxy.example.com",
|
|
343
344
|
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
344
345
|
),
|
|
345
346
|
)
|
|
@@ -355,12 +356,22 @@ client.with_options(http_client=DefaultHttpxClient(...))
|
|
|
355
356
|
|
|
356
357
|
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.
|
|
357
358
|
|
|
359
|
+
```py
|
|
360
|
+
from prelude_python_sdk import Prelude
|
|
361
|
+
|
|
362
|
+
with Prelude() as client:
|
|
363
|
+
# make requests here
|
|
364
|
+
...
|
|
365
|
+
|
|
366
|
+
# HTTP client is now closed
|
|
367
|
+
```
|
|
368
|
+
|
|
358
369
|
## Versioning
|
|
359
370
|
|
|
360
371
|
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:
|
|
361
372
|
|
|
362
373
|
1. Changes that only affect static types, without breaking runtime behavior.
|
|
363
|
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_
|
|
374
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
364
375
|
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
365
376
|
|
|
366
377
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
@@ -116,7 +116,7 @@ except prelude_python_sdk.APIStatusError as e:
|
|
|
116
116
|
print(e.response)
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
Error codes are as
|
|
119
|
+
Error codes are as follows:
|
|
120
120
|
|
|
121
121
|
| Status Code | Error Type |
|
|
122
122
|
| ----------- | -------------------------- |
|
|
@@ -267,8 +267,7 @@ If you need to access undocumented endpoints, params, or response properties, th
|
|
|
267
267
|
#### Undocumented endpoints
|
|
268
268
|
|
|
269
269
|
To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
|
|
270
|
-
http verbs. Options on the client will be respected (such as retries)
|
|
271
|
-
request.
|
|
270
|
+
http verbs. Options on the client will be respected (such as retries) when making this request.
|
|
272
271
|
|
|
273
272
|
```py
|
|
274
273
|
import httpx
|
|
@@ -297,18 +296,19 @@ can also get all the extra fields on the Pydantic model as a dict with
|
|
|
297
296
|
|
|
298
297
|
You can directly override the [httpx client](https://www.python-httpx.org/api/#client) to customize it for your use case, including:
|
|
299
298
|
|
|
300
|
-
- Support for proxies
|
|
301
|
-
- Custom transports
|
|
299
|
+
- Support for [proxies](https://www.python-httpx.org/advanced/proxies/)
|
|
300
|
+
- Custom [transports](https://www.python-httpx.org/advanced/transports/)
|
|
302
301
|
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality
|
|
303
302
|
|
|
304
303
|
```python
|
|
304
|
+
import httpx
|
|
305
305
|
from prelude_python_sdk import Prelude, DefaultHttpxClient
|
|
306
306
|
|
|
307
307
|
client = Prelude(
|
|
308
308
|
# Or use the `PRELUDE_BASE_URL` env var
|
|
309
309
|
base_url="http://my.test.server.example.com:8083",
|
|
310
310
|
http_client=DefaultHttpxClient(
|
|
311
|
-
|
|
311
|
+
proxy="http://my.test.proxy.example.com",
|
|
312
312
|
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
313
313
|
),
|
|
314
314
|
)
|
|
@@ -324,12 +324,22 @@ client.with_options(http_client=DefaultHttpxClient(...))
|
|
|
324
324
|
|
|
325
325
|
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.
|
|
326
326
|
|
|
327
|
+
```py
|
|
328
|
+
from prelude_python_sdk import Prelude
|
|
329
|
+
|
|
330
|
+
with Prelude() as client:
|
|
331
|
+
# make requests here
|
|
332
|
+
...
|
|
333
|
+
|
|
334
|
+
# HTTP client is now closed
|
|
335
|
+
```
|
|
336
|
+
|
|
327
337
|
## Versioning
|
|
328
338
|
|
|
329
339
|
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:
|
|
330
340
|
|
|
331
341
|
1. Changes that only affect static types, without breaking runtime behavior.
|
|
332
|
-
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_
|
|
342
|
+
2. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
|
|
333
343
|
3. Changes that we do not expect to impact the vast majority of users in practice.
|
|
334
344
|
|
|
335
345
|
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "prelude-python-sdk"
|
|
3
|
-
version = "0.1.0-alpha.
|
|
3
|
+
version = "0.1.0-alpha.7"
|
|
4
4
|
description = "The official Python library for the Prelude 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",
|
|
@@ -54,7 +54,7 @@ dev-dependencies = [
|
|
|
54
54
|
"dirty-equals>=0.6.0",
|
|
55
55
|
"importlib-metadata>=6.7.0",
|
|
56
56
|
"rich>=13.7.1",
|
|
57
|
-
"nest_asyncio==1.6.0"
|
|
57
|
+
"nest_asyncio==1.6.0",
|
|
58
58
|
]
|
|
59
59
|
|
|
60
60
|
[tool.rye.scripts]
|
|
@@ -35,7 +35,7 @@ h11==0.14.0
|
|
|
35
35
|
# via httpcore
|
|
36
36
|
httpcore==1.0.2
|
|
37
37
|
# via httpx
|
|
38
|
-
httpx==0.
|
|
38
|
+
httpx==0.28.1
|
|
39
39
|
# via prelude-python-sdk
|
|
40
40
|
# via respx
|
|
41
41
|
idna==3.4
|
|
@@ -62,13 +62,13 @@ platformdirs==3.11.0
|
|
|
62
62
|
# via virtualenv
|
|
63
63
|
pluggy==1.5.0
|
|
64
64
|
# via pytest
|
|
65
|
-
pydantic==2.
|
|
65
|
+
pydantic==2.10.3
|
|
66
66
|
# via prelude-python-sdk
|
|
67
|
-
pydantic-core==2.
|
|
67
|
+
pydantic-core==2.27.1
|
|
68
68
|
# via pydantic
|
|
69
69
|
pygments==2.18.0
|
|
70
70
|
# via rich
|
|
71
|
-
pyright==1.1.
|
|
71
|
+
pyright==1.1.390
|
|
72
72
|
pytest==8.3.3
|
|
73
73
|
# via pytest-asyncio
|
|
74
74
|
pytest-asyncio==0.24.0
|
|
@@ -76,7 +76,7 @@ python-dateutil==2.8.2
|
|
|
76
76
|
# via time-machine
|
|
77
77
|
pytz==2023.3.post1
|
|
78
78
|
# via dirty-equals
|
|
79
|
-
respx==0.
|
|
79
|
+
respx==0.22.0
|
|
80
80
|
rich==13.7.1
|
|
81
81
|
ruff==0.6.9
|
|
82
82
|
setuptools==68.2.2
|
|
@@ -85,7 +85,6 @@ six==1.16.0
|
|
|
85
85
|
# via python-dateutil
|
|
86
86
|
sniffio==1.3.0
|
|
87
87
|
# via anyio
|
|
88
|
-
# via httpx
|
|
89
88
|
# via prelude-python-sdk
|
|
90
89
|
time-machine==2.9.0
|
|
91
90
|
tomli==2.0.2
|
|
@@ -25,18 +25,17 @@ h11==0.14.0
|
|
|
25
25
|
# via httpcore
|
|
26
26
|
httpcore==1.0.2
|
|
27
27
|
# via httpx
|
|
28
|
-
httpx==0.
|
|
28
|
+
httpx==0.28.1
|
|
29
29
|
# via prelude-python-sdk
|
|
30
30
|
idna==3.4
|
|
31
31
|
# via anyio
|
|
32
32
|
# via httpx
|
|
33
|
-
pydantic==2.
|
|
33
|
+
pydantic==2.10.3
|
|
34
34
|
# via prelude-python-sdk
|
|
35
|
-
pydantic-core==2.
|
|
35
|
+
pydantic-core==2.27.1
|
|
36
36
|
# via pydantic
|
|
37
37
|
sniffio==1.3.0
|
|
38
38
|
# via anyio
|
|
39
|
-
# via httpx
|
|
40
39
|
# via prelude-python-sdk
|
|
41
40
|
typing-extensions==4.12.2
|
|
42
41
|
# via anyio
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/__init__.py
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
from . import types
|
|
4
|
-
from ._types import NOT_GIVEN, NoneType, NotGiven, Transport, ProxiesTypes
|
|
4
|
+
from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes
|
|
5
5
|
from ._utils import file_from_path
|
|
6
6
|
from ._client import Client, Stream, Prelude, Timeout, Transport, AsyncClient, AsyncStream, AsyncPrelude, RequestOptions
|
|
7
7
|
from ._models import BaseModel
|
|
@@ -36,6 +36,7 @@ __all__ = [
|
|
|
36
36
|
"ProxiesTypes",
|
|
37
37
|
"NotGiven",
|
|
38
38
|
"NOT_GIVEN",
|
|
39
|
+
"Omit",
|
|
39
40
|
"PreludeError",
|
|
40
41
|
"APIError",
|
|
41
42
|
"APIStatusError",
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_base_client.py
RENAMED
|
@@ -767,6 +767,9 @@ else:
|
|
|
767
767
|
|
|
768
768
|
class SyncHttpxClientWrapper(DefaultHttpxClient):
|
|
769
769
|
def __del__(self) -> None:
|
|
770
|
+
if self.is_closed:
|
|
771
|
+
return
|
|
772
|
+
|
|
770
773
|
try:
|
|
771
774
|
self.close()
|
|
772
775
|
except Exception:
|
|
@@ -1334,6 +1337,9 @@ else:
|
|
|
1334
1337
|
|
|
1335
1338
|
class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
|
|
1336
1339
|
def __del__(self) -> None:
|
|
1340
|
+
if self.is_closed:
|
|
1341
|
+
return
|
|
1342
|
+
|
|
1337
1343
|
try:
|
|
1338
1344
|
# TODO(someday): support non asyncio runtimes here
|
|
1339
1345
|
asyncio.get_running_loop().create_task(self.aclose())
|
|
@@ -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 watch, verification, transactional
|
|
27
28
|
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
|
|
28
29
|
from ._exceptions import PreludeError, APIStatusError
|
|
29
30
|
from ._base_client import (
|
|
@@ -32,23 +33,13 @@ from ._base_client import (
|
|
|
32
33
|
AsyncAPIClient,
|
|
33
34
|
)
|
|
34
35
|
|
|
35
|
-
__all__ = [
|
|
36
|
-
"Timeout",
|
|
37
|
-
"Transport",
|
|
38
|
-
"ProxiesTypes",
|
|
39
|
-
"RequestOptions",
|
|
40
|
-
"resources",
|
|
41
|
-
"Prelude",
|
|
42
|
-
"AsyncPrelude",
|
|
43
|
-
"Client",
|
|
44
|
-
"AsyncClient",
|
|
45
|
-
]
|
|
36
|
+
__all__ = ["Timeout", "Transport", "ProxiesTypes", "RequestOptions", "Prelude", "AsyncPrelude", "Client", "AsyncClient"]
|
|
46
37
|
|
|
47
38
|
|
|
48
39
|
class Prelude(SyncAPIClient):
|
|
49
|
-
transactional:
|
|
50
|
-
verification:
|
|
51
|
-
watch:
|
|
40
|
+
transactional: transactional.TransactionalResource
|
|
41
|
+
verification: verification.VerificationResource
|
|
42
|
+
watch: watch.WatchResource
|
|
52
43
|
with_raw_response: PreludeWithRawResponse
|
|
53
44
|
with_streaming_response: PreludeWithStreamedResponse
|
|
54
45
|
|
|
@@ -106,9 +97,9 @@ class Prelude(SyncAPIClient):
|
|
|
106
97
|
_strict_response_validation=_strict_response_validation,
|
|
107
98
|
)
|
|
108
99
|
|
|
109
|
-
self.transactional =
|
|
110
|
-
self.verification =
|
|
111
|
-
self.watch =
|
|
100
|
+
self.transactional = transactional.TransactionalResource(self)
|
|
101
|
+
self.verification = verification.VerificationResource(self)
|
|
102
|
+
self.watch = watch.WatchResource(self)
|
|
112
103
|
self.with_raw_response = PreludeWithRawResponse(self)
|
|
113
104
|
self.with_streaming_response = PreludeWithStreamedResponse(self)
|
|
114
105
|
|
|
@@ -218,9 +209,9 @@ class Prelude(SyncAPIClient):
|
|
|
218
209
|
|
|
219
210
|
|
|
220
211
|
class AsyncPrelude(AsyncAPIClient):
|
|
221
|
-
transactional:
|
|
222
|
-
verification:
|
|
223
|
-
watch:
|
|
212
|
+
transactional: transactional.AsyncTransactionalResource
|
|
213
|
+
verification: verification.AsyncVerificationResource
|
|
214
|
+
watch: watch.AsyncWatchResource
|
|
224
215
|
with_raw_response: AsyncPreludeWithRawResponse
|
|
225
216
|
with_streaming_response: AsyncPreludeWithStreamedResponse
|
|
226
217
|
|
|
@@ -278,9 +269,9 @@ class AsyncPrelude(AsyncAPIClient):
|
|
|
278
269
|
_strict_response_validation=_strict_response_validation,
|
|
279
270
|
)
|
|
280
271
|
|
|
281
|
-
self.transactional =
|
|
282
|
-
self.verification =
|
|
283
|
-
self.watch =
|
|
272
|
+
self.transactional = transactional.AsyncTransactionalResource(self)
|
|
273
|
+
self.verification = verification.AsyncVerificationResource(self)
|
|
274
|
+
self.watch = watch.AsyncWatchResource(self)
|
|
284
275
|
self.with_raw_response = AsyncPreludeWithRawResponse(self)
|
|
285
276
|
self.with_streaming_response = AsyncPreludeWithStreamedResponse(self)
|
|
286
277
|
|
|
@@ -391,30 +382,30 @@ class AsyncPrelude(AsyncAPIClient):
|
|
|
391
382
|
|
|
392
383
|
class PreludeWithRawResponse:
|
|
393
384
|
def __init__(self, client: Prelude) -> None:
|
|
394
|
-
self.transactional =
|
|
395
|
-
self.verification =
|
|
396
|
-
self.watch =
|
|
385
|
+
self.transactional = transactional.TransactionalResourceWithRawResponse(client.transactional)
|
|
386
|
+
self.verification = verification.VerificationResourceWithRawResponse(client.verification)
|
|
387
|
+
self.watch = watch.WatchResourceWithRawResponse(client.watch)
|
|
397
388
|
|
|
398
389
|
|
|
399
390
|
class AsyncPreludeWithRawResponse:
|
|
400
391
|
def __init__(self, client: AsyncPrelude) -> None:
|
|
401
|
-
self.transactional =
|
|
402
|
-
self.verification =
|
|
403
|
-
self.watch =
|
|
392
|
+
self.transactional = transactional.AsyncTransactionalResourceWithRawResponse(client.transactional)
|
|
393
|
+
self.verification = verification.AsyncVerificationResourceWithRawResponse(client.verification)
|
|
394
|
+
self.watch = watch.AsyncWatchResourceWithRawResponse(client.watch)
|
|
404
395
|
|
|
405
396
|
|
|
406
397
|
class PreludeWithStreamedResponse:
|
|
407
398
|
def __init__(self, client: Prelude) -> None:
|
|
408
|
-
self.transactional =
|
|
409
|
-
self.verification =
|
|
410
|
-
self.watch =
|
|
399
|
+
self.transactional = transactional.TransactionalResourceWithStreamingResponse(client.transactional)
|
|
400
|
+
self.verification = verification.VerificationResourceWithStreamingResponse(client.verification)
|
|
401
|
+
self.watch = watch.WatchResourceWithStreamingResponse(client.watch)
|
|
411
402
|
|
|
412
403
|
|
|
413
404
|
class AsyncPreludeWithStreamedResponse:
|
|
414
405
|
def __init__(self, client: AsyncPrelude) -> None:
|
|
415
|
-
self.transactional =
|
|
416
|
-
self.verification =
|
|
417
|
-
self.watch =
|
|
406
|
+
self.transactional = transactional.AsyncTransactionalResourceWithStreamingResponse(client.transactional)
|
|
407
|
+
self.verification = verification.AsyncVerificationResourceWithStreamingResponse(client.verification)
|
|
408
|
+
self.watch = watch.AsyncWatchResourceWithStreamingResponse(client.watch)
|
|
418
409
|
|
|
419
410
|
|
|
420
411
|
Client = Prelude
|
|
@@ -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_):
|
|
@@ -485,7 +488,11 @@ def construct_type(*, value: object, type_: object) -> object:
|
|
|
485
488
|
_, items_type = get_args(type_) # Dict[_, items_type]
|
|
486
489
|
return {key: construct_type(value=item, type_=items_type) for key, item in value.items()}
|
|
487
490
|
|
|
488
|
-
if
|
|
491
|
+
if (
|
|
492
|
+
not is_literal_type(type_)
|
|
493
|
+
and inspect.isclass(origin)
|
|
494
|
+
and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel))
|
|
495
|
+
):
|
|
489
496
|
if is_list(value):
|
|
490
497
|
return [cast(Any, type_).construct(**entry) if is_mapping(entry) else entry for entry in value]
|
|
491
498
|
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_response.py
RENAMED
|
@@ -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
|
|
|
@@ -192,10 +192,8 @@ ResponseT = TypeVar(
|
|
|
192
192
|
StrBytesIntFloat = Union[str, bytes, int, float]
|
|
193
193
|
|
|
194
194
|
# Note: copied from Pydantic
|
|
195
|
-
# https://github.com/pydantic/pydantic/blob/
|
|
196
|
-
IncEx: TypeAlias = Union[
|
|
197
|
-
Set[int], Set[str], Mapping[int, Union["IncEx", Literal[True]]], Mapping[str, Union["IncEx", Literal[True]]]
|
|
198
|
-
]
|
|
195
|
+
# https://github.com/pydantic/pydantic/blob/6f31f8f68ef011f84357330186f603ff295312fd/pydantic/main.py#L79
|
|
196
|
+
IncEx: TypeAlias = Union[Set[int], Set[str], Mapping[int, Union["IncEx", bool]], Mapping[str, Union["IncEx", bool]]]
|
|
199
197
|
|
|
200
198
|
PostParser = Callable[[Any], Any]
|
|
201
199
|
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/__init__.py
RENAMED
|
@@ -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
|
)
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_typing.py
RENAMED
|
@@ -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):
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing_extensions import Literal, Required, TypedDict
|
|
6
6
|
|
|
7
|
-
__all__ = ["VerificationCreateParams", "Target", "Metadata", "Options", "Signals"]
|
|
7
|
+
__all__ = ["VerificationCreateParams", "Target", "Metadata", "Options", "OptionsAppRealm", "Signals"]
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class VerificationCreateParams(TypedDict, total=False):
|
|
@@ -38,12 +38,29 @@ class Metadata(TypedDict, total=False):
|
|
|
38
38
|
"""A user-defined identifier to correlate this verification with."""
|
|
39
39
|
|
|
40
40
|
|
|
41
|
+
class OptionsAppRealm(TypedDict, total=False):
|
|
42
|
+
platform: Required[Literal["android"]]
|
|
43
|
+
"""The platform the SMS will be sent to.
|
|
44
|
+
|
|
45
|
+
We are currently only supporting "android".
|
|
46
|
+
"""
|
|
47
|
+
|
|
48
|
+
value: Required[str]
|
|
49
|
+
"""The Android SMS Retriever API hash code that identifies your app."""
|
|
50
|
+
|
|
51
|
+
|
|
41
52
|
class Options(TypedDict, total=False):
|
|
42
|
-
app_realm:
|
|
43
|
-
"""
|
|
53
|
+
app_realm: OptionsAppRealm
|
|
54
|
+
"""This allows you to automatically retrieve and fill the OTP code on mobile apps.
|
|
55
|
+
|
|
56
|
+
Currently only Android devices are supported.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
code_size: int
|
|
60
|
+
"""The size of the code generated.
|
|
44
61
|
|
|
45
|
-
|
|
46
|
-
|
|
62
|
+
It should be between 4 and 8. Defaults to the code size specified from the
|
|
63
|
+
Dashboard.
|
|
47
64
|
"""
|
|
48
65
|
|
|
49
66
|
custom_code: str
|
|
@@ -95,7 +112,7 @@ class Signals(TypedDict, total=False):
|
|
|
95
112
|
ip: str
|
|
96
113
|
"""The IP address of the user's device."""
|
|
97
114
|
|
|
98
|
-
is_trusted_user:
|
|
115
|
+
is_trusted_user: bool
|
|
99
116
|
"""
|
|
100
117
|
This signal should provide a higher level of trust, indicating that the user is
|
|
101
118
|
genuine. For more details, refer to [Signals](/guides/prevent-fraud#signals).
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/api_resources/test_verification.py
RENAMED
|
@@ -39,7 +39,11 @@ class TestVerification:
|
|
|
39
39
|
},
|
|
40
40
|
metadata={"correlation_id": "correlation_id"},
|
|
41
41
|
options={
|
|
42
|
-
"app_realm":
|
|
42
|
+
"app_realm": {
|
|
43
|
+
"platform": "android",
|
|
44
|
+
"value": "value",
|
|
45
|
+
},
|
|
46
|
+
"code_size": 5,
|
|
43
47
|
"custom_code": "custom_code",
|
|
44
48
|
"locale": "el-GR",
|
|
45
49
|
"sender_id": "sender_id",
|
|
@@ -51,7 +55,7 @@ class TestVerification:
|
|
|
51
55
|
"device_model": "iPhone17,2",
|
|
52
56
|
"device_platform": "android",
|
|
53
57
|
"ip": "192.0.2.1",
|
|
54
|
-
"is_trusted_user":
|
|
58
|
+
"is_trusted_user": False,
|
|
55
59
|
"os_version": "18.0.1",
|
|
56
60
|
},
|
|
57
61
|
)
|
|
@@ -153,7 +157,11 @@ class TestAsyncVerification:
|
|
|
153
157
|
},
|
|
154
158
|
metadata={"correlation_id": "correlation_id"},
|
|
155
159
|
options={
|
|
156
|
-
"app_realm":
|
|
160
|
+
"app_realm": {
|
|
161
|
+
"platform": "android",
|
|
162
|
+
"value": "value",
|
|
163
|
+
},
|
|
164
|
+
"code_size": 5,
|
|
157
165
|
"custom_code": "custom_code",
|
|
158
166
|
"locale": "el-GR",
|
|
159
167
|
"sender_id": "sender_id",
|
|
@@ -165,7 +173,7 @@ class TestAsyncVerification:
|
|
|
165
173
|
"device_model": "iPhone17,2",
|
|
166
174
|
"device_platform": "android",
|
|
167
175
|
"ip": "192.0.2.1",
|
|
168
|
-
"is_trusted_user":
|
|
176
|
+
"is_trusted_user": False,
|
|
169
177
|
"os_version": "18.0.1",
|
|
170
178
|
},
|
|
171
179
|
)
|
|
@@ -358,11 +358,11 @@ class TestPrelude:
|
|
|
358
358
|
FinalRequestOptions(
|
|
359
359
|
method="get",
|
|
360
360
|
url="/foo",
|
|
361
|
-
params={"foo": "baz", "query_param": "
|
|
361
|
+
params={"foo": "baz", "query_param": "overridden"},
|
|
362
362
|
)
|
|
363
363
|
)
|
|
364
364
|
url = httpx.URL(request.url)
|
|
365
|
-
assert dict(url.params) == {"foo": "baz", "query_param": "
|
|
365
|
+
assert dict(url.params) == {"foo": "baz", "query_param": "overridden"}
|
|
366
366
|
|
|
367
367
|
def test_request_extra_json(self) -> None:
|
|
368
368
|
request = self.client._build_request(
|
|
@@ -1166,11 +1166,11 @@ class TestAsyncPrelude:
|
|
|
1166
1166
|
FinalRequestOptions(
|
|
1167
1167
|
method="get",
|
|
1168
1168
|
url="/foo",
|
|
1169
|
-
params={"foo": "baz", "query_param": "
|
|
1169
|
+
params={"foo": "baz", "query_param": "overridden"},
|
|
1170
1170
|
)
|
|
1171
1171
|
)
|
|
1172
1172
|
url = httpx.URL(request.url)
|
|
1173
|
-
assert dict(url.params) == {"foo": "baz", "query_param": "
|
|
1173
|
+
assert dict(url.params) == {"foo": "baz", "query_param": "overridden"}
|
|
1174
1174
|
|
|
1175
1175
|
def test_request_extra_json(self) -> None:
|
|
1176
1176
|
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 prelude_python_sdk._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 prelude_python_sdk._compat import PYDANTIC_V2, field_outer_type, get_model_fields
|
|
21
22
|
from prelude_python_sdk._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
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_constants.py
RENAMED
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_exceptions.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_resource.py
RENAMED
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_streaming.py
RENAMED
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_logs.py
RENAMED
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_proxy.py
RENAMED
|
File without changes
|
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_streams.py
RENAMED
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_sync.py
RENAMED
|
File without changes
|
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/_utils/_utils.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/resources/watch.py
RENAMED
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/src/prelude_python_sdk/types/__init__.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{prelude_python_sdk-0.1.0a5 → prelude_python_sdk-0.1.0a7}/tests/api_resources/test_transactional.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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|