diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml deleted file mode 100644 index b34bb18..0000000 --- a/.github/workflows/publish-pypi.yml +++ /dev/null @@ -1,31 +0,0 @@ -# This workflow is triggered when a GitHub release is created. -# It can also be run manually to re-publish to PyPI in case it failed for some reason. -# You can run this workflow by navigating to https://www.github.com/orbcorp/orb-python/actions/workflows/publish-pypi.yml -name: Publish PyPI -on: - workflow_dispatch: - - release: - types: [published] - -jobs: - publish: - name: publish - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Install Rye - run: | - curl -sSf https://rye.astral.sh/get | bash - echo "$HOME/.rye/shims" >> $GITHUB_PATH - env: - RYE_VERSION: '0.44.0' - RYE_INSTALL_OPTION: '--yes' - - - name: Publish to PyPI - run: | - bash ./bin/publish-pypi - env: - PYPI_TOKEN: ${{ secrets.ORB_PYPI_TOKEN || secrets.PYPI_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml deleted file mode 100644 index 3425083..0000000 --- a/.github/workflows/release-doctor.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Release Doctor -on: - pull_request: - branches: - - main - workflow_dispatch: - -jobs: - release_doctor: - name: release doctor - runs-on: ubuntu-latest - if: github.repository == 'orbcorp/orb-python' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') - - steps: - - uses: actions/checkout@v4 - - - name: Check release environment - run: | - bash ./bin/check-release-environment - env: - PYPI_TOKEN: ${{ secrets.ORB_PYPI_TOKEN || secrets.PYPI_TOKEN }} diff --git a/.python-version b/.python-version index 375f5ca..43077b2 100644 --- a/.python-version +++ b/.python-version @@ -1 +1 @@ -3.11.6 +3.9.18 diff --git a/scripts/apply-customizations.sh b/scripts/apply-customizations.sh index 18bf69e..8561451 100755 --- a/scripts/apply-customizations.sh +++ b/scripts/apply-customizations.sh @@ -24,6 +24,20 @@ find tests -name "*.py" -exec sed -i 's/from orb$/from orb_sdk/g' {} + find tests -name "*.py" -exec sed -i 's/import orb\([^_]\)/import orb_sdk\1/g' {} + find tests -name "*.py" -exec sed -i 's/import orb$/import orb_sdk/g' {} + +# Update mock.patch strings and error messages in tests +echo "Updating mock.patch and error message strings in tests/" +find tests -name "*.py" -exec sed -i "s/\"orb\._/\"orb_sdk._/g" {} + +find tests -name "*.py" -exec sed -i "s/'orb\._/'orb_sdk._/g" {} + + +# Update scripts/lint import check +echo "Updating scripts/lint import check" +sed -i "s/python -c 'import orb'/python -c 'import orb_sdk'/" scripts/lint + +# Remove pydantic v1 tests (we only use pydantic v2) +echo "Removing pydantic v1 tests from scripts/test" +sed -i '/Running Pydantic v1 tests/d' scripts/test +sed -i '/nox -s test-pydantic-v1/d' scripts/test + # Update pyproject.toml echo "Updating pyproject.toml" sed -i 's/name = "orb-billing"/name = "orb_sdk"/' pyproject.toml diff --git a/scripts/lint b/scripts/lint index 38b82fa..ee17e57 100755 --- a/scripts/lint +++ b/scripts/lint @@ -8,4 +8,4 @@ echo "==> Running lints" rye run lint echo "==> Making sure it imports" -rye run python -c 'import orb' +rye run python -c 'import orb_sdk' diff --git a/scripts/test b/scripts/test index dbeda2d..2c69d99 100755 --- a/scripts/test +++ b/scripts/test @@ -56,6 +56,3 @@ export DEFER_PYDANTIC_BUILD=false echo "==> Running tests" rye run pytest "$@" - -echo "==> Running Pydantic v1 tests" -rye run nox -s test-pydantic-v1 -- "$@" diff --git a/tests/test_client.py b/tests/test_client.py index b550138..5401eb7 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -752,7 +752,7 @@ def test_parse_retry_after_header( calculated = client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, client: Orb) -> None: respx_mock.post("/customers").mock(side_effect=httpx.TimeoutException("Test timeout error")) @@ -762,7 +762,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien assert _get_open_connections(client) == 0 - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client: Orb) -> None: respx_mock.post("/customers").mock(return_value=httpx.Response(500)) @@ -772,7 +772,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client assert _get_open_connections(client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.parametrize("failure_mode", ["status", "exception"]) def test_retries_taken( @@ -803,7 +803,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_omit_retry_count_header(self, client: Orb, failures_before_success: int, respx_mock: MockRouter) -> None: client = client.with_options(max_retries=4) @@ -826,7 +826,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_overwrite_retry_count_header( self, client: Orb, failures_before_success: int, respx_mock: MockRouter @@ -851,7 +851,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert response.http_request.headers.get("x-stainless-retry-count") == "42" @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retries_taken_new_response_class( self, client: Orb, failures_before_success: int, respx_mock: MockRouter @@ -1630,7 +1630,7 @@ async def test_parse_retry_after_header( calculated = async_client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncOrb) -> None: respx_mock.post("/customers").mock(side_effect=httpx.TimeoutException("Test timeout error")) @@ -1642,7 +1642,7 @@ async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, assert _get_open_connections(async_client) == 0 - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, async_client: AsyncOrb) -> None: respx_mock.post("/customers").mock(return_value=httpx.Response(500)) @@ -1654,7 +1654,7 @@ async def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, assert _get_open_connections(async_client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @pytest.mark.parametrize("failure_mode", ["status", "exception"]) async def test_retries_taken( @@ -1685,7 +1685,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert int(response.http_request.headers.get("x-stainless-retry-count")) == failures_before_success @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_omit_retry_count_header( self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter @@ -1710,7 +1710,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert len(response.http_request.headers.get_list("x-stainless-retry-count")) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_overwrite_retry_count_header( self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter @@ -1735,7 +1735,7 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert response.http_request.headers.get("x-stainless-retry-count") == "42" @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) + @mock.patch("orb_sdk._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retries_taken_new_response_class( self, async_client: AsyncOrb, failures_before_success: int, respx_mock: MockRouter diff --git a/tests/test_response.py b/tests/test_response.py index ed1311b..16845b9 100644 --- a/tests/test_response.py +++ b/tests/test_response.py @@ -37,7 +37,7 @@ def test_extract_response_type_direct_classes() -> None: def test_extract_response_type_direct_class_missing_type_arg() -> None: with pytest.raises( RuntimeError, - match="Expected type to have a type argument at index 0 but it did not", + match="Expected type to have a type argument at index 0 but it did not", ): extract_response_type(AsyncAPIResponse)