Skip to content

Commit

Permalink
chore: update SDK settings (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 14, 2024
1 parent e34a3f3 commit ea056d4
Show file tree
Hide file tree
Showing 66 changed files with 125 additions and 118 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $ pip install -r requirements-dev.lock

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
result in merge conflicts between manual patches and changes from the generator. The generator will never
modify the contents of the `src/prelude_sdk/lib/` and `examples/` directories.
modify the contents of the `src/prelude_python_sdk/lib/` and `examples/` directories.

## Adding and running examples

Expand Down
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Prelude Python API library

[![PyPI version](https://img.shields.io/pypi/v/prelude-sdk.svg)](https://pypi.org/project/prelude-sdk/)
[![PyPI version](https://img.shields.io/pypi/v/prelude-python-sdk.svg)](https://pypi.org/project/prelude-python-sdk/)

The Prelude Python library provides convenient access to the Prelude REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand All @@ -16,7 +16,7 @@ The REST API documentation can be found on [docs.prelude.so](https://docs.prelud

```sh
# install from PyPI
pip install --pre prelude-sdk
pip install --pre prelude-python-sdk
```

## Usage
Expand All @@ -25,7 +25,7 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from prelude_sdk import Prelude
from prelude_python_sdk import Prelude

client = Prelude(
api_token=os.environ.get("API_TOKEN"), # This is the default and can be omitted
Expand All @@ -52,7 +52,7 @@ Simply import `AsyncPrelude` instead of `Prelude` and use `await` with each API
```python
import os
import asyncio
from prelude_sdk import AsyncPrelude
from prelude_python_sdk import AsyncPrelude

client = AsyncPrelude(
api_token=os.environ.get("API_TOKEN"), # This is the default and can be omitted
Expand Down Expand Up @@ -85,16 +85,16 @@ Typed requests and responses provide autocomplete and documentation within your

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `prelude_sdk.APIConnectionError` is raised.
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `prelude_python_sdk.APIConnectionError` is raised.

When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of `prelude_sdk.APIStatusError` is raised, containing `status_code` and `response` properties.
response), a subclass of `prelude_python_sdk.APIStatusError` is raised, containing `status_code` and `response` properties.

All errors inherit from `prelude_sdk.APIError`.
All errors inherit from `prelude_python_sdk.APIError`.

```python
import prelude_sdk
from prelude_sdk import Prelude
import prelude_python_sdk
from prelude_python_sdk import Prelude

client = Prelude()

Expand All @@ -105,12 +105,12 @@ try:
"value": "+30123456789",
},
)
except prelude_sdk.APIConnectionError as e:
except prelude_python_sdk.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except prelude_sdk.RateLimitError as e:
except prelude_python_sdk.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except prelude_sdk.APIStatusError as e:
except prelude_python_sdk.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
Expand Down Expand Up @@ -138,7 +138,7 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from prelude_sdk import Prelude
from prelude_python_sdk import Prelude

# Configure the default for all requests:
client = Prelude(
Expand All @@ -161,7 +161,7 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from prelude_sdk import Prelude
from prelude_python_sdk import Prelude

# Configure the default for all requests:
client = Prelude(
Expand Down Expand Up @@ -216,7 +216,7 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,

```py
from prelude_sdk import Prelude
from prelude_python_sdk import Prelude

client = Prelude()
response = client.verification.with_raw_response.create(
Expand All @@ -231,9 +231,9 @@ verification = response.parse() # get the object that `verification.create()` w
print(verification.id)
```

These methods return an [`APIResponse`](https://github.com/prelude-so/python-sdk/tree/main/src/prelude_sdk/_response.py) object.
These methods return an [`APIResponse`](https://github.com/prelude-so/python-sdk/tree/main/src/prelude_python_sdk/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/prelude-so/python-sdk/tree/main/src/prelude_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/prelude-so/python-sdk/tree/main/src/prelude_python_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

Expand Down Expand Up @@ -300,7 +300,7 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c
- Additional [advanced](https://www.python-httpx.org/advanced/clients/) functionality

```python
from prelude_sdk import Prelude, DefaultHttpxClient
from prelude_python_sdk import Prelude, DefaultHttpxClient

client = Prelude(
# Or use the `PRELUDE_BASE_URL` env var
Expand Down Expand Up @@ -341,8 +341,8 @@ If you've upgraded to the latest version but aren't seeing any new features you
You can determine the version that is being used at runtime with:

```py
import prelude_sdk
print(prelude_sdk.__version__)
import prelude_python_sdk
print(prelude_python_sdk.__version__)
```

## Requirements
Expand Down
16 changes: 8 additions & 8 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,35 @@
Types:

```python
from prelude_sdk.types import TransactionalSendResponse
from prelude_python_sdk.types import TransactionalSendResponse
```

Methods:

- <code title="post /v2/transactional">client.transactional.<a href="./src/prelude_sdk/resources/transactional.py">send</a>(\*\*<a href="src/prelude_sdk/types/transactional_send_params.py">params</a>) -> <a href="./src/prelude_sdk/types/transactional_send_response.py">TransactionalSendResponse</a></code>
- <code title="post /v2/transactional">client.transactional.<a href="./src/prelude_python_sdk/resources/transactional.py">send</a>(\*\*<a href="src/prelude_python_sdk/types/transactional_send_params.py">params</a>) -> <a href="./src/prelude_python_sdk/types/transactional_send_response.py">TransactionalSendResponse</a></code>

# Verification

Types:

```python
from prelude_sdk.types import VerificationCreateResponse, VerificationCheckResponse
from prelude_python_sdk.types import VerificationCreateResponse, VerificationCheckResponse
```

Methods:

- <code title="post /v2/verification">client.verification.<a href="./src/prelude_sdk/resources/verification.py">create</a>(\*\*<a href="src/prelude_sdk/types/verification_create_params.py">params</a>) -> <a href="./src/prelude_sdk/types/verification_create_response.py">VerificationCreateResponse</a></code>
- <code title="post /v2/verification/check">client.verification.<a href="./src/prelude_sdk/resources/verification.py">check</a>(\*\*<a href="src/prelude_sdk/types/verification_check_params.py">params</a>) -> <a href="./src/prelude_sdk/types/verification_check_response.py">VerificationCheckResponse</a></code>
- <code title="post /v2/verification">client.verification.<a href="./src/prelude_python_sdk/resources/verification.py">create</a>(\*\*<a href="src/prelude_python_sdk/types/verification_create_params.py">params</a>) -> <a href="./src/prelude_python_sdk/types/verification_create_response.py">VerificationCreateResponse</a></code>
- <code title="post /v2/verification/check">client.verification.<a href="./src/prelude_python_sdk/resources/verification.py">check</a>(\*\*<a href="src/prelude_python_sdk/types/verification_check_params.py">params</a>) -> <a href="./src/prelude_python_sdk/types/verification_check_response.py">VerificationCheckResponse</a></code>

# Watch

Types:

```python
from prelude_sdk.types import WatchFeedBackResponse, WatchPredictResponse
from prelude_python_sdk.types import WatchFeedBackResponse, WatchPredictResponse
```

Methods:

- <code title="post /v2/watch/feedback">client.watch.<a href="./src/prelude_sdk/resources/watch.py">feed_back</a>(\*\*<a href="src/prelude_sdk/types/watch_feed_back_params.py">params</a>) -> <a href="./src/prelude_sdk/types/watch_feed_back_response.py">WatchFeedBackResponse</a></code>
- <code title="post /v2/watch/predict">client.watch.<a href="./src/prelude_sdk/resources/watch.py">predict</a>(\*\*<a href="src/prelude_sdk/types/watch_predict_params.py">params</a>) -> <a href="./src/prelude_sdk/types/watch_predict_response.py">WatchPredictResponse</a></code>
- <code title="post /v2/watch/feedback">client.watch.<a href="./src/prelude_python_sdk/resources/watch.py">feed_back</a>(\*\*<a href="src/prelude_python_sdk/types/watch_feed_back_params.py">params</a>) -> <a href="./src/prelude_python_sdk/types/watch_feed_back_response.py">WatchFeedBackResponse</a></code>
- <code title="post /v2/watch/predict">client.watch.<a href="./src/prelude_python_sdk/resources/watch.py">predict</a>(\*\*<a href="src/prelude_python_sdk/types/watch_predict_params.py">params</a>) -> <a href="./src/prelude_python_sdk/types/watch_predict_response.py">WatchPredictResponse</a></code>
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ show_error_codes = True
# Exclude _files.py because mypy isn't smart enough to apply
# the correct type narrowing and as this is an internal module
# it's fine to just use Pyright.
exclude = ^(src/prelude_sdk/_files\.py|_dev/.*\.py)$
exclude = ^(src/prelude_python_sdk/_files\.py|_dev/.*\.py)$

strict_equality = True
implicit_reexport = True
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[project]
name = "prelude-sdk"
name = "prelude-python-sdk"
version = "0.1.0-alpha.2"
description = "The official Python library for the Prelude API"
dynamic = ["readme"]
Expand Down Expand Up @@ -76,14 +76,14 @@ format = { chain = [
"check:ruff" = "ruff check ."
"fix:ruff" = "ruff check --fix ."

"check:importable" = "python -c 'import prelude_sdk'"
"check:importable" = "python -c 'import prelude_python_sdk'"

typecheck = { chain = [
"typecheck:pyright",
"typecheck:mypy"
]}
"typecheck:pyright" = "pyright"
"typecheck:verify-types" = "pyright --verifytypes prelude_sdk --ignoreexternal"
"typecheck:verify-types" = "pyright --verifytypes prelude_python_sdk --ignoreexternal"
"typecheck:mypy" = "mypy ."

[build-system]
Expand All @@ -96,7 +96,7 @@ include = [
]

[tool.hatch.build.targets.wheel]
packages = ["src/prelude_sdk"]
packages = ["src/prelude_python_sdk"]

[tool.hatch.build.targets.sdist]
# Basically everything except hidden files/directories (such as .github, .devcontainers, .python-version, etc)
Expand Down Expand Up @@ -198,7 +198,7 @@ length-sort = true
length-sort-straight = true
combine-as-imports = true
extra-standard-library = ["typing_extensions"]
known-first-party = ["prelude_sdk", "tests"]
known-first-party = ["prelude_python_sdk", "tests"]

[tool.ruff.lint.per-file-ignores]
"bin/**.py" = ["T201", "T203"]
Expand Down
2 changes: 1 addition & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
],
"release-type": "python",
"extra-files": [
"src/prelude_sdk/_version.py"
"src/prelude_python_sdk/_version.py"
]
}
12 changes: 6 additions & 6 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via prelude-sdk
# via prelude-python-sdk
argcomplete==3.1.2
# via nox
certifi==2023.7.22
Expand All @@ -25,7 +25,7 @@ dirty-equals==0.6.0
distlib==0.3.7
# via virtualenv
distro==1.8.0
# via prelude-sdk
# via prelude-python-sdk
exceptiongroup==1.2.2
# via anyio
# via pytest
Expand All @@ -36,7 +36,7 @@ h11==0.14.0
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via prelude-sdk
# via prelude-python-sdk
# via respx
idna==3.4
# via anyio
Expand All @@ -62,7 +62,7 @@ platformdirs==3.11.0
pluggy==1.5.0
# via pytest
pydantic==2.9.2
# via prelude-sdk
# via prelude-python-sdk
pydantic-core==2.23.4
# via pydantic
pygments==2.18.0
Expand All @@ -85,15 +85,15 @@ six==1.16.0
sniffio==1.3.0
# via anyio
# via httpx
# via prelude-sdk
# via prelude-python-sdk
time-machine==2.9.0
tomli==2.0.2
# via mypy
# via pytest
typing-extensions==4.12.2
# via anyio
# via mypy
# via prelude-sdk
# via prelude-python-sdk
# via pydantic
# via pydantic-core
virtualenv==20.24.5
Expand Down
12 changes: 6 additions & 6 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@ annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via prelude-sdk
# via prelude-python-sdk
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via prelude-sdk
# via prelude-python-sdk
exceptiongroup==1.2.2
# via anyio
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
# via prelude-sdk
# via prelude-python-sdk
idna==3.4
# via anyio
# via httpx
pydantic==2.9.2
# via prelude-sdk
# via prelude-python-sdk
pydantic-core==2.23.4
# via pydantic
sniffio==1.3.0
# via anyio
# via httpx
# via prelude-sdk
# via prelude-python-sdk
typing-extensions==4.12.2
# via anyio
# via prelude-sdk
# via prelude-python-sdk
# via pydantic
# via pydantic-core
2 changes: 1 addition & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ echo "==> Running lints"
rye run lint

echo "==> Making sure it imports"
rye run python -c 'import prelude_sdk'
rye run python -c 'import prelude_python_sdk'

Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,12 @@
# Update the __module__ attribute for exported symbols so that
# error messages point to this module instead of the module
# it was originally defined in, e.g.
# prelude_sdk._exceptions.NotFoundError -> prelude_sdk.NotFoundError
# prelude_python_sdk._exceptions.NotFoundError -> prelude_python_sdk.NotFoundError
__locals = locals()
for __name in __all__:
if not __name.startswith("__"):
try:
__locals[__name].__module__ = "prelude_sdk"
__locals[__name].__module__ = "prelude_python_sdk"
except (TypeError, AttributeError):
# Some of our exported symbols are builtins which we can't set attributes for.
pass
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def __init__(

if max_retries is None: # pyright: ignore[reportUnnecessaryComparison]
raise TypeError(
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `prelude_sdk.DEFAULT_MAX_RETRIES`"
"max_retries cannot be None. If you want to disable retries, pass `0`; if you want unlimited retries, pass `math.inf` or a very high number; if you want the default behavior, pass `prelude_python_sdk.DEFAULT_MAX_RETRIES`"
)

def _enforce_trailing_slash(self, url: URL) -> URL:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit ea056d4

Please sign in to comment.