diff --git a/.release-please-manifest.json b/.release-please-manifest.json index a817334f..7a0ae8af 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "4.14.0" + ".": "4.14.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 369abc0f..3157e497 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 4.14.1 (2025-09-08) + +Full Changelog: [v4.14.0...v4.14.1](https://github.com/orbcorp/orb-python/compare/v4.14.0...v4.14.1) + +### Bug Fixes + +* **types:** add missing types to method arguments ([ad3dc7d](https://github.com/orbcorp/orb-python/commit/ad3dc7d0d1d7a20d2a5d3e68000e793e6bc4afd5)) + + +### Chores + +* **tests:** simplify `get_platform` test ([dd4f6e1](https://github.com/orbcorp/orb-python/commit/dd4f6e1394dc2ddf53dc791658d300ebe321f8a8)) + ## 4.14.0 (2025-09-05) Full Changelog: [v4.13.0...v4.14.0](https://github.com/orbcorp/orb-python/compare/v4.13.0...v4.14.0) diff --git a/pyproject.toml b/pyproject.toml index 8b02ba29..82f964ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "orb-billing" -version = "4.14.0" +version = "4.14.1" description = "The official Python library for the orb API" dynamic = ["readme"] license = "Apache-2.0" @@ -56,7 +56,6 @@ dev-dependencies = [ "dirty-equals>=0.6.0", "importlib-metadata>=6.7.0", "rich>=13.7.1", - "nest_asyncio==1.6.0", "pytest-xdist>=3.6.1", ] diff --git a/requirements-dev.lock b/requirements-dev.lock index 1fef201f..32438c4a 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -75,7 +75,6 @@ multidict==6.4.4 mypy==1.14.1 mypy-extensions==1.0.0 # via mypy -nest-asyncio==1.6.0 nodeenv==1.8.0 # via pyright nox==2023.4.22 diff --git a/src/orb/_version.py b/src/orb/_version.py index dfc6f577..5abbf098 100644 --- a/src/orb/_version.py +++ b/src/orb/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "orb" -__version__ = "4.14.0" # x-release-please-version +__version__ = "4.14.1" # x-release-please-version diff --git a/src/orb/resources/customers/credits/ledger.py b/src/orb/resources/customers/credits/ledger.py index a8951af5..8126a58d 100644 --- a/src/orb/resources/customers/credits/ledger.py +++ b/src/orb/resources/customers/credits/ledger.py @@ -1041,7 +1041,7 @@ def create_entry( self, customer_id: str, *, - amount: float | None | NotGiven = NOT_GIVEN, + amount: float | Optional[float] | NotGiven = NOT_GIVEN, entry_type: Literal["increment"] | Literal["decrement"] | Literal["expiration_change"] @@ -1056,7 +1056,7 @@ def create_entry( metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN, per_unit_cost_basis: Optional[str] | NotGiven = NOT_GIVEN, target_expiry_date: Union[str, date] | NotGiven = NOT_GIVEN, - block_id: Optional[str] | NotGiven = NOT_GIVEN, + block_id: Optional[str] | str | NotGiven = NOT_GIVEN, void_reason: Optional[Literal["refund"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -1933,7 +1933,7 @@ def create_entry_by_external_id( self, external_customer_id: str, *, - amount: float | None | NotGiven = NOT_GIVEN, + amount: float | Optional[float] | NotGiven = NOT_GIVEN, entry_type: Literal["increment"] | Literal["decrement"] | Literal["expiration_change"] @@ -1950,7 +1950,7 @@ def create_entry_by_external_id( metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN, per_unit_cost_basis: Optional[str] | NotGiven = NOT_GIVEN, target_expiry_date: Union[str, date] | NotGiven = NOT_GIVEN, - block_id: Optional[str] | NotGiven = NOT_GIVEN, + block_id: Optional[str] | str | NotGiven = NOT_GIVEN, void_reason: Optional[Literal["refund"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -3172,7 +3172,7 @@ async def create_entry( self, customer_id: str, *, - amount: float | None | NotGiven = NOT_GIVEN, + amount: float | Optional[float] | NotGiven = NOT_GIVEN, entry_type: Literal["increment"] | Literal["decrement"] | Literal["expiration_change"] @@ -3187,7 +3187,7 @@ async def create_entry( metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN, per_unit_cost_basis: Optional[str] | NotGiven = NOT_GIVEN, target_expiry_date: Union[str, date] | NotGiven = NOT_GIVEN, - block_id: Optional[str] | NotGiven = NOT_GIVEN, + block_id: Optional[str] | str | NotGiven = NOT_GIVEN, void_reason: Optional[Literal["refund"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -4064,7 +4064,7 @@ async def create_entry_by_external_id( self, external_customer_id: str, *, - amount: float | None | NotGiven = NOT_GIVEN, + amount: float | Optional[float] | NotGiven = NOT_GIVEN, entry_type: Literal["increment"] | Literal["decrement"] | Literal["expiration_change"] @@ -4081,7 +4081,7 @@ async def create_entry_by_external_id( metadata: Optional[Dict[str, Optional[str]]] | NotGiven = NOT_GIVEN, per_unit_cost_basis: Optional[str] | NotGiven = NOT_GIVEN, target_expiry_date: Union[str, date] | NotGiven = NOT_GIVEN, - block_id: Optional[str] | NotGiven = NOT_GIVEN, + block_id: Optional[str] | str | NotGiven = NOT_GIVEN, void_reason: Optional[Literal["refund"]] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. diff --git a/src/orb/resources/prices/prices.py b/src/orb/resources/prices/prices.py index 6c27b2a3..8bea7f59 100644 --- a/src/orb/resources/prices/prices.py +++ b/src/orb/resources/prices/prices.py @@ -2745,6 +2745,32 @@ def create( billing_cycle_configuration: Optional[NewBillingCycleConfiguration] | NotGiven = NOT_GIVEN, conversion_rate: Optional[float] | NotGiven = NOT_GIVEN, conversion_rate_config: Optional[price_create_params.NewFloatingUnitPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingBulkPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMatrixPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingThresholdTotalAmountPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredWithMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedTieredPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredPackageWithMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingPackageWithAllocationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingUnitWithPercentPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMatrixWithAllocationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredWithProrationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingUnitWithProrationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedAllocationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingBulkWithProrationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedWithProratedMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedWithMeteredMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedWithMinMaxThresholdsPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMatrixWithDisplayNamePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedTieredPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMaxGroupTieredPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingScalableMatrixWithUnitPricingPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingScalableMatrixWithTieredPricingPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingCumulativeGroupedBulkPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMinimumCompositePriceConversionRateConfig] | NotGiven = NOT_GIVEN, dimensional_price_configuration: Optional[NewDimensionalPriceConfiguration] | NotGiven = NOT_GIVEN, external_price_id: Optional[str] | NotGiven = NOT_GIVEN, @@ -5974,6 +6000,32 @@ async def create( billing_cycle_configuration: Optional[NewBillingCycleConfiguration] | NotGiven = NOT_GIVEN, conversion_rate: Optional[float] | NotGiven = NOT_GIVEN, conversion_rate_config: Optional[price_create_params.NewFloatingUnitPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingBulkPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMatrixPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingThresholdTotalAmountPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredWithMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedTieredPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredPackageWithMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingPackageWithAllocationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingUnitWithPercentPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMatrixWithAllocationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingTieredWithProrationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingUnitWithProrationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedAllocationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingBulkWithProrationPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedWithProratedMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedWithMeteredMinimumPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedWithMinMaxThresholdsPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMatrixWithDisplayNamePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingGroupedTieredPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMaxGroupTieredPackagePriceConversionRateConfig] + | Optional[price_create_params.NewFloatingScalableMatrixWithUnitPricingPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingScalableMatrixWithTieredPricingPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingCumulativeGroupedBulkPriceConversionRateConfig] + | Optional[price_create_params.NewFloatingMinimumCompositePriceConversionRateConfig] | NotGiven = NOT_GIVEN, dimensional_price_configuration: Optional[NewDimensionalPriceConfiguration] | NotGiven = NOT_GIVEN, external_price_id: Optional[str] | NotGiven = NOT_GIVEN, diff --git a/tests/test_client.py b/tests/test_client.py index c9a672f7..3637c947 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,13 +6,10 @@ import os import sys import json -import time import asyncio import inspect -import subprocess import tracemalloc from typing import Any, Union, cast -from textwrap import dedent from unittest import mock from typing_extensions import Literal @@ -23,14 +20,17 @@ from orb import Orb, AsyncOrb, APIResponseValidationError from orb._types import Omit +from orb._utils import asyncify from orb._models import BaseModel, FinalRequestOptions from orb._exceptions import OrbError, APIStatusError, APITimeoutError, APIResponseValidationError from orb._base_client import ( DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, + OtherPlatform, DefaultHttpxClient, DefaultAsyncHttpxClient, + get_platform, make_request_options, ) @@ -1724,50 +1724,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert response.retries_taken == failures_before_success assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success - def test_get_platform(self) -> None: - # A previous implementation of asyncify could leave threads unterminated when - # used with nest_asyncio. - # - # Since nest_asyncio.apply() is global and cannot be un-applied, this - # test is run in a separate process to avoid affecting other tests. - test_code = dedent(""" - import asyncio - import nest_asyncio - import threading - - from orb._utils import asyncify - from orb._base_client import get_platform - - async def test_main() -> None: - result = await asyncify(get_platform)() - print(result) - for thread in threading.enumerate(): - print(thread.name) - - nest_asyncio.apply() - asyncio.run(test_main()) - """) - with subprocess.Popen( - [sys.executable, "-c", test_code], - text=True, - ) as process: - timeout = 10 # seconds - - start_time = time.monotonic() - while True: - return_code = process.poll() - if return_code is not None: - if return_code != 0: - raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") - - # success - break - - if time.monotonic() - start_time > timeout: - process.kill() - raise AssertionError("calling get_platform using asyncify resulted in a hung process") - - time.sleep(0.1) + async def test_get_platform(self) -> None: + platform = await asyncify(get_platform)() + assert isinstance(platform, (str, OtherPlatform)) async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: # Test that the proxy environment variables are set correctly