Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
lint:
name: lint
runs-on: ubuntu-latest


steps:
- uses: actions/checkout@v4
Expand All @@ -30,6 +29,7 @@ jobs:

- name: Run lints
run: ./scripts/lint

test:
name: test
runs-on: ubuntu-latest
Expand All @@ -50,4 +50,3 @@ jobs:

- name: Run tests
run: ./scripts/test

2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.2.2"
".": "1.2.3"
}
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Changelog

## 1.2.3 (2025-01-25)

Full Changelog: [v1.2.2...v1.2.3](https://github.com/lumalabs/lumaai-python/compare/v1.2.2...v1.2.3)

### Bug Fixes

* **client:** only call .close() when needed ([#86](https://github.com/lumalabs/lumaai-python/issues/86)) ([edfe052](https://github.com/lumalabs/lumaai-python/commit/edfe052f365e25084dc5fc3fcd6536e8ca7caad8))
* correctly handle deserialising `cls` fields ([#88](https://github.com/lumalabs/lumaai-python/issues/88)) ([05474de](https://github.com/lumalabs/lumaai-python/commit/05474de956b6fbf237a5024fe1bf52c43619ab49))


### Chores

* add missing isclass check ([#84](https://github.com/lumalabs/lumaai-python/issues/84)) ([0f25a20](https://github.com/lumalabs/lumaai-python/commit/0f25a2007de69c2c86fdf6ce3cd354a68371d06f))
* **internal:** bump httpx dependency ([#85](https://github.com/lumalabs/lumaai-python/issues/85)) ([7fc347f](https://github.com/lumalabs/lumaai-python/commit/7fc347ff9d25901b1066feeddcf7992db392486d))
* **internal:** codegen related update ([#81](https://github.com/lumalabs/lumaai-python/issues/81)) ([4b141ed](https://github.com/lumalabs/lumaai-python/commit/4b141ed4e9dc448a5f5a4365d90d251ecd3f4534))
* **internal:** codegen related update ([#83](https://github.com/lumalabs/lumaai-python/issues/83)) ([f2eb603](https://github.com/lumalabs/lumaai-python/commit/f2eb603e6f936ee987d1dcdcee7126d0fdb16111))
* **internal:** codegen related update ([#87](https://github.com/lumalabs/lumaai-python/issues/87)) ([e8d60ba](https://github.com/lumalabs/lumaai-python/commit/e8d60ba7d411d640610462fc792612e9ecc22365))
* **internal:** codegen related update ([#89](https://github.com/lumalabs/lumaai-python/issues/89)) ([6bf0844](https://github.com/lumalabs/lumaai-python/commit/6bf0844b8601e49697e7ac0552333e1a271a4be3))
* **internal:** codegen related update ([#90](https://github.com/lumalabs/lumaai-python/issues/90)) ([1b4f8a8](https://github.com/lumalabs/lumaai-python/commit/1b4f8a88c251437472e41a4ed44c827ceb5cbcf8))
* **internal:** codegen related update ([#92](https://github.com/lumalabs/lumaai-python/issues/92)) ([9aca177](https://github.com/lumalabs/lumaai-python/commit/9aca177ee2028c96b47ec79c660ff6c1de335470))
* **internal:** minor style changes ([#91](https://github.com/lumalabs/lumaai-python/issues/91)) ([afb1e46](https://github.com/lumalabs/lumaai-python/commit/afb1e468f2f65ed5a8ab6e9ba2654a801ac813a4))

## 1.2.2 (2024-12-17)

Full Changelog: [v1.2.1...v1.2.2](https://github.com/lumalabs/lumaai-python/compare/v1.2.1...v1.2.2)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2024 LumaAI
Copyright 2025 LumaAI

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ except lumaai.APIStatusError as e:
print(e.response)
```

Error codes are as followed:
Error codes are as follows:

| Status Code | Error Type |
| ----------- | -------------------------- |
Expand Down Expand Up @@ -258,8 +258,7 @@ If you need to access undocumented endpoints, params, or response properties, th
#### Undocumented endpoints

To make requests to undocumented endpoints, you can make requests using `client.get`, `client.post`, and other
http verbs. Options on the client will be respected (such as retries) will be respected when making this
request.
http verbs. Options on the client will be respected (such as retries) when making this request.

```py
import httpx
Expand Down Expand Up @@ -331,7 +330,7 @@ with LumaAI() as client:
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. Changes that only affect static types, without breaking runtime behavior.
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)_.
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.)_
3. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
Expand Down
2 changes: 1 addition & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ cache_fine_grained = True
# ```
# Changing this codegen to make mypy happy would increase complexity
# and would not be worth it.
disable_error_code = func-returns-value
disable_error_code = func-returns-value,overload-cannot-match

# https://github.com/python/mypy/issues/12162
[mypy.overrides]
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "lumaai"
version = "1.2.2"
version = "1.2.3"
description = "The official Python library for the lumaai API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -54,7 +54,7 @@ dev-dependencies = [
"dirty-equals>=0.6.0",
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0"
"nest_asyncio==1.6.0",
]

[tool.rye.scripts]
Expand Down Expand Up @@ -129,6 +129,7 @@ testpaths = ["tests"]
addopts = "--tb=short"
xfail_strict = true
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
filterwarnings = [
"error"
]
Expand Down
9 changes: 4 additions & 5 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
httpx==0.28.1
# via lumaai
# via respx
idna==3.4
Expand All @@ -48,7 +48,7 @@ markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.13.0
mypy==1.14.1
mypy-extensions==1.0.0
# via mypy
nest-asyncio==1.6.0
Expand All @@ -68,15 +68,15 @@ pydantic-core==2.27.1
# via pydantic
pygments==2.18.0
# via rich
pyright==1.1.390
pyright==1.1.392.post0
pytest==8.3.3
# via pytest-asyncio
pytest-asyncio==0.24.0
python-dateutil==2.8.2
# via time-machine
pytz==2023.3.post1
# via dirty-equals
respx==0.20.2
respx==0.22.0
rich==13.7.1
ruff==0.6.9
setuptools==68.2.2
Expand All @@ -85,7 +85,6 @@ six==1.16.0
# via python-dateutil
sniffio==1.3.0
# via anyio
# via httpx
# via lumaai
time-machine==2.9.0
tomli==2.0.2
Expand Down
3 changes: 1 addition & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.25.2
httpx==0.28.1
# via lumaai
idna==3.4
# via anyio
Expand All @@ -36,7 +36,6 @@ pydantic-core==2.27.1
# via pydantic
sniffio==1.3.0
# via anyio
# via httpx
# via lumaai
typing-extensions==4.12.2
# via anyio
Expand Down
2 changes: 1 addition & 1 deletion scripts/bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -e

cd "$(dirname "$0")/.."

if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then
brew bundle check >/dev/null 2>&1 || {
echo "==> Installing Homebrew dependencies…"
brew bundle
Expand Down
1 change: 0 additions & 1 deletion scripts/lint
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ rye run lint

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

6 changes: 6 additions & 0 deletions src/lumaai/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,9 @@ def __init__(self, **kwargs: Any) -> None:

class SyncHttpxClientWrapper(DefaultHttpxClient):
def __del__(self) -> None:
if self.is_closed:
return

try:
self.close()
except Exception:
Expand Down Expand Up @@ -1334,6 +1337,9 @@ def __init__(self, **kwargs: Any) -> None:

class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
def __del__(self) -> None:
if self.is_closed:
return

try:
# TODO(someday): support non asyncio runtimes here
asyncio.get_running_loop().create_task(self.aclose())
Expand Down
14 changes: 9 additions & 5 deletions src/lumaai/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ def __str__(self) -> str:
@classmethod
@override
def construct( # pyright: ignore[reportIncompatibleMethodOverride]
cls: Type[ModelT],
__cls: Type[ModelT],
_fields_set: set[str] | None = None,
**values: object,
) -> ModelT:
m = cls.__new__(cls)
m = __cls.__new__(__cls)
fields_values: dict[str, object] = {}

config = get_model_config(cls)
config = get_model_config(__cls)
populate_by_name = (
config.allow_population_by_field_name
if isinstance(config, _ConfigProtocol)
Expand All @@ -196,7 +196,7 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride]
if _fields_set is None:
_fields_set = set()

model_fields = get_model_fields(cls)
model_fields = get_model_fields(__cls)
for name, field in model_fields.items():
key = field.alias
if key is None or (key not in values and populate_by_name):
Expand Down Expand Up @@ -488,7 +488,11 @@ def construct_type(*, value: object, type_: object) -> object:
_, items_type = get_args(type_) # Dict[_, items_type]
return {key: construct_type(value=item, type_=items_type) for key, item in value.items()}

if not is_literal_type(type_) and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel)):
if (
not is_literal_type(type_)
and inspect.isclass(origin)
and (issubclass(origin, BaseModel) or issubclass(origin, GenericModel))
):
if is_list(value):
return [cast(Any, type_).construct(**entry) if is_mapping(entry) else entry for entry in value]

Expand Down
12 changes: 9 additions & 3 deletions src/lumaai/_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
if cast_to and is_annotated_type(cast_to):
cast_to = extract_type_arg(cast_to, 0)

origin = get_origin(cast_to) or cast_to

if self._is_sse_stream:
if to:
if not is_stream_class_type(to):
Expand Down Expand Up @@ -195,8 +197,6 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
if cast_to == bool:
return cast(R, response.text.lower() == "true")

origin = get_origin(cast_to) or cast_to

if origin == APIResponse:
raise RuntimeError("Unexpected state - cast_to is `APIResponse`")

Expand All @@ -210,7 +210,13 @@ def _parse(self, *, to: type[_T] | None = None) -> R | _T:
raise ValueError(f"Subclasses of httpx.Response cannot be passed to `cast_to`")
return cast(R, response)

if inspect.isclass(origin) and not issubclass(origin, BaseModel) and issubclass(origin, pydantic.BaseModel):
if (
inspect.isclass(
origin # pyright: ignore[reportUnknownArgumentType]
)
and not issubclass(origin, BaseModel)
and issubclass(origin, pydantic.BaseModel)
):
raise TypeError("Pydantic models must subclass our base model type, e.g. `from lumaai import BaseModel`")

if (
Expand Down
2 changes: 1 addition & 1 deletion src/lumaai/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "lumaai"
__version__ = "1.2.2" # x-release-please-version
__version__ = "1.2.3" # x-release-please-version
4 changes: 2 additions & 2 deletions src/lumaai/resources/credits.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CreditsResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> CreditsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down Expand Up @@ -63,7 +63,7 @@ class AsyncCreditsResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncCreditsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down
4 changes: 2 additions & 2 deletions src/lumaai/resources/generations/camera_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CameraMotionResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> CameraMotionResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down Expand Up @@ -63,7 +63,7 @@ class AsyncCameraMotionResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncCameraMotionResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down
4 changes: 2 additions & 2 deletions src/lumaai/resources/generations/generations.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def video(self) -> VideoResource:
@cached_property
def with_raw_response(self) -> GenerationsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down Expand Up @@ -268,7 +268,7 @@ def video(self) -> AsyncVideoResource:
@cached_property
def with_raw_response(self) -> AsyncGenerationsResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down
4 changes: 2 additions & 2 deletions src/lumaai/resources/generations/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ImageResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> ImageResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down Expand Up @@ -115,7 +115,7 @@ class AsyncImageResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncImageResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down
4 changes: 2 additions & 2 deletions src/lumaai/resources/generations/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class VideoResource(SyncAPIResource):
@cached_property
def with_raw_response(self) -> VideoResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down Expand Up @@ -110,7 +110,7 @@ class AsyncVideoResource(AsyncAPIResource):
@cached_property
def with_raw_response(self) -> AsyncVideoResourceWithRawResponse:
"""
This property can be used as a prefix for any HTTP method call to return the
This property can be used as a prefix for any HTTP method call to return
the raw response object instead of the parsed content.

For more information, see https://www.github.com/lumalabs/lumaai-python#accessing-raw-response-data-eg-headers
Expand Down
Loading
Loading