From 76f685a24c7ca01c003d9b32be71eadf397a1bd0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 12:40:20 +0000 Subject: [PATCH 1/5] chore(internal): avoid errors for isinstance checks on proxies --- src/lithic/_utils/_proxy.py | 5 ++++- tests/test_utils/test_proxy.py | 11 +++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lithic/_utils/_proxy.py b/src/lithic/_utils/_proxy.py index ffd883e9..0f239a33 100644 --- a/src/lithic/_utils/_proxy.py +++ b/src/lithic/_utils/_proxy.py @@ -46,7 +46,10 @@ def __dir__(self) -> Iterable[str]: @property # type: ignore @override def __class__(self) -> type: # pyright: ignore - proxied = self.__get_proxied__() + try: + proxied = self.__get_proxied__() + except Exception: + return type(self) if issubclass(type(proxied), LazyProxy): return type(proxied) return proxied.__class__ diff --git a/tests/test_utils/test_proxy.py b/tests/test_utils/test_proxy.py index de5da111..1b0c9c0f 100644 --- a/tests/test_utils/test_proxy.py +++ b/tests/test_utils/test_proxy.py @@ -21,3 +21,14 @@ def test_recursive_proxy() -> None: assert dir(proxy) == [] assert type(proxy).__name__ == "RecursiveLazyProxy" assert type(operator.attrgetter("name.foo.bar.baz")(proxy)).__name__ == "RecursiveLazyProxy" + + +def test_isinstance_does_not_error() -> None: + class AlwaysErrorProxy(LazyProxy[Any]): + @override + def __load__(self) -> Any: + raise RuntimeError("Mocking missing dependency") + + proxy = AlwaysErrorProxy() + assert not isinstance(proxy, dict) + assert isinstance(proxy, LazyProxy) From a8baae96c80ebebb09b24d08b4399ad3facbf6c6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 8 May 2025 16:02:26 +0000 Subject: [PATCH 2/5] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 5917ddd7..f1b4b0a5 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 156 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-8469aee20249c9dcb2b57796df62fd39d2c14668a6853476b6c1bab9c80a4e4c.yml openapi_spec_hash: 3339f9fd912f2eb8ba5efc3c73f5d030 -config_hash: d4866815848851db2d5fe85d4ddcbede +config_hash: 620bf845d9ccfaf0ad7e2452463bb227 From 9402b87c62b52b79c1d4d18460e78736f4e8598d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 14:27:22 +0000 Subject: [PATCH 3/5] docs: remove or fix invalid readme examples --- README.md | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/README.md b/README.md index 93380fa4..ab54834e 100644 --- a/README.md +++ b/README.md @@ -142,20 +142,6 @@ for card in first_page.data: # Remove `await` for non-async usage. ``` -## Nested params - -Nested parameters are dictionaries, typed using `TypedDict`, for example: - -```python -from lithic import Lithic - -client = Lithic() - -card = client.cards.create( - type="VIRTUAL", -) -``` - ## Webhook Verification We provide helper methods for verifying that a webhook request came from Lithic, and not a malicious third party. @@ -196,7 +182,7 @@ client = Lithic() try: client.cards.create( - type="an_incorrect_type", + type="MERCHANT_LOCKED", ) except lithic.APIConnectionError as e: print("The server could not be reached") From bca9fdd588d1c683a21e4d9da78e8816637f61b9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 14:23:21 +0000 Subject: [PATCH 4/5] fix(package): support direct resource imports --- src/lithic/__init__.py | 5 +++++ src/lithic/_utils/_resources_proxy.py | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/lithic/_utils/_resources_proxy.py diff --git a/src/lithic/__init__.py b/src/lithic/__init__.py index f847e185..155e7648 100644 --- a/src/lithic/__init__.py +++ b/src/lithic/__init__.py @@ -1,5 +1,7 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +import typing as _t + from . import types from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes from ._utils import file_from_path @@ -80,6 +82,9 @@ "DefaultAsyncHttpxClient", ] +if not _t.TYPE_CHECKING: + from ._utils._resources_proxy import resources as resources + _setup_logging() # Update the __module__ attribute for exported symbols so that diff --git a/src/lithic/_utils/_resources_proxy.py b/src/lithic/_utils/_resources_proxy.py new file mode 100644 index 00000000..efa0c112 --- /dev/null +++ b/src/lithic/_utils/_resources_proxy.py @@ -0,0 +1,24 @@ +from __future__ import annotations + +from typing import Any +from typing_extensions import override + +from ._proxy import LazyProxy + + +class ResourcesProxy(LazyProxy[Any]): + """A proxy for the `lithic.resources` module. + + This is used so that we can lazily import `lithic.resources` only when + needed *and* so that users can just import `lithic` and reference `lithic.resources` + """ + + @override + def __load__(self) -> Any: + import importlib + + mod = importlib.import_module("lithic.resources") + return mod + + +resources = ResourcesProxy().__as_proxied__() From ed2c3b935b42890c3bcd420c62014168389265ac Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 May 2025 14:27:53 +0000 Subject: [PATCH 5/5] release: 0.91.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 18 ++++++++++++++++++ pyproject.toml | 2 +- src/lithic/_version.py | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index d448f4f5..857b235a 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.91.1" + ".": "0.91.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 51fdd67d..7cb76c75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.91.2 (2025-05-09) + +Full Changelog: [v0.91.1...v0.91.2](https://github.com/lithic-com/lithic-python/compare/v0.91.1...v0.91.2) + +### Bug Fixes + +* **package:** support direct resource imports ([bca9fdd](https://github.com/lithic-com/lithic-python/commit/bca9fdd588d1c683a21e4d9da78e8816637f61b9)) + + +### Chores + +* **internal:** avoid errors for isinstance checks on proxies ([76f685a](https://github.com/lithic-com/lithic-python/commit/76f685a24c7ca01c003d9b32be71eadf397a1bd0)) + + +### Documentation + +* remove or fix invalid readme examples ([9402b87](https://github.com/lithic-com/lithic-python/commit/9402b87c62b52b79c1d4d18460e78736f4e8598d)) + ## 0.91.1 (2025-05-05) Full Changelog: [v0.91.0...v0.91.1](https://github.com/lithic-com/lithic-python/compare/v0.91.0...v0.91.1) diff --git a/pyproject.toml b/pyproject.toml index b96bb5b7..f29cd8b5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lithic" -version = "0.91.1" +version = "0.91.2" description = "The official Python library for the lithic API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/lithic/_version.py b/src/lithic/_version.py index b8893725..20550971 100644 --- a/src/lithic/_version.py +++ b/src/lithic/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "lithic" -__version__ = "0.91.1" # x-release-please-version +__version__ = "0.91.2" # x-release-please-version