### v6 SyncPage example Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of iterating over a `SyncPage` object in v6. ```python page = client.organizations.list_organizations() for organization in page: print(organization.id) assert page.before is None or isinstance(page.before, str) assert page.after is None or isinstance(page.after, str) ``` -------------------------------- ### v5 Client Construction Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of client construction in v5. ```python from workos import WorkOSClient client = WorkOSClient(api_key="sk_test_123", client_id="client_123") ``` -------------------------------- ### v5 authenticate_with_code example Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of using `session=` with `authenticate_with_code` in v5. ```python response = client.user_management.authenticate_with_code( code=code, session={"seal_session": True, "cookie_password": COOKIE_PASSWORD}, ) sealed = response.sealed_session ``` -------------------------------- ### v6 AsyncPage example Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of iterating over an `AsyncPage` object in v6. ```python page = await async_client.organizations.list_organizations() items = [organization async for organization in page] ``` -------------------------------- ### v6 authenticate_with_code example Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of using `authenticate_with_code` in v6, with manual session sealing. ```python from workos.session import seal_session_from_auth_response response = client.user_management.authenticate_with_code(code=code) sealed = seal_session_from_auth_response( access_token=response.access_token, refresh_token=response.refresh_token, user=response.user.to_dict(), impersonator=( response.impersonator.to_dict() if response.impersonator else None ), cookie_password=COOKIE_PASSWORD, ) ``` -------------------------------- ### v6 Client Construction Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Examples of client construction in v6, showing different configurations. ```python from workos import WorkOSClient server_client = WorkOSClient(api_key="sk_test_123") public_client = WorkOSClient(client_id="client_123") hybrid_client = WorkOSClient(api_key="sk_test_123", client_id="client_123") ``` -------------------------------- ### v5 Model Imports Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of model imports in v5. ```python from workos.types.organizations.organization import Organization from workos.types.portal.portal_link_intent import PortalLinkIntent ``` -------------------------------- ### v5 authenticate_with_code with session=None Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of passing `session=None` in v5. ```python # v5 response = client.user_management.authenticate_with_code(code=code, session=None) ``` -------------------------------- ### v6 Model Imports Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of preferred model imports in v6. ```python from workos.organizations.models import Organization from workos.common.models import GenerateLinkIntent ``` -------------------------------- ### Quick Start - Asynchronous Client Source: https://github.com/workos/workos-python/blob/main/README.md Demonstrates the asynchronous counterpart for client methods. ```python from workos import AsyncWorkOSClient async_client = AsyncWorkOSClient(api_key="sk_1234", client_id="client_1234") page = await async_client.organizations.list_organizations() async for org in page.auto_paging_iter(): print(org.name) ``` -------------------------------- ### v6 Temporary Compatibility Imports Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of temporary compatibility imports in v6. ```python from workos.types.organizations import Organization ``` -------------------------------- ### v6 WorkOSClient with max_retries=0 Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of initializing `WorkOSClient` with `max_retries=0` to disable default retries. ```python from workos import WorkOSClient client = WorkOSClient(api_key="sk_test_123", max_retries=0) ``` -------------------------------- ### Quick Start - Synchronous Client Source: https://github.com/workos/workos-python/blob/main/README.md Initialize the WorkOS client and perform basic operations like listing and creating organizations. ```python from workos import WorkOSClient client = WorkOSClient(api_key="sk_1234", client_id="client_1234") # List organizations page = client.organizations.list_organizations() for org in page.auto_paging_iter(): print(org.name) # Create an organization org = client.organizations.create_organizations(name="Acme Corp") print(org.id) ``` -------------------------------- ### v6 authenticate_with_code with broader sealed payload Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of sealing the full auth response in v6 for behavior closer to v5. ```python from workos.session import seal_data response = client.user_management.authenticate_with_code(code=code) sealed = seal_data(response.to_dict(), COOKIE_PASSWORD) ``` -------------------------------- ### v6 authenticate_with_code with session=None Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of dropping the `session=` argument in v6 when it was `None` in v5. ```python # v6 response = client.user_management.authenticate_with_code(code=code) ``` -------------------------------- ### Install package in development mode Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Installs the package in development mode, including dev dependencies, using uv sync with locked dependencies. ```bash uv sync --locked --dev # Install package in development mode with dev dependencies ``` -------------------------------- ### Exception classes were renamed and normalized Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Illustrates the change in exception naming from `*Exception` to `*Error` and provides examples of old and new exception handling. ```python from workos.exceptions import NotFoundException try: client.organizations.get_organization("org_123") except NotFoundException: ... ``` ```python from workos import NotFoundError try: client.organizations.get_organization("org_123") except NotFoundError as exc: request_id = exc.request_id status_code = exc.status_code ``` -------------------------------- ### v6 request_options for per-request retry override Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Example of overriding retry behavior for a specific request using `request_options`. ```python from workos import WorkOSClient client = WorkOSClient(api_key="sk_test_123") client.organizations.list_organizations( request_options={ "timeout": 5, "max_retries": 0, } ) ``` -------------------------------- ### Search Command Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Shell command to search for specific patterns during migration. ```shell rg 'workos\.client|workos\.async_client|client\.portal|client\.fga|model_dump|model_validate|Exception|workos\.types|session=|seal_session' ``` -------------------------------- ### Installation Source: https://github.com/workos/workos-python/blob/main/README.md Install the WorkOS Python library using pip. ```bash pip install workos ``` -------------------------------- ### `fga` is removed Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Shows the removal of the `client.fga` accessor in v6. ```python fga = client.fga ``` ```python # No v6 replacement is available in this branch. ``` -------------------------------- ### Old client module paths were removed Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Illustrates the change in import paths for WorkOS client classes from v5 to v6. ```python from workos.client import WorkOSClient from workos.async_client import AsyncWorkOSClient ``` ```python from workos import WorkOSClient, AsyncWorkOSClient ``` -------------------------------- ### Python 3.10+ is now required Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Comparison of Python version requirements between v5 and v6 of the WorkOS Python SDK. ```toml [project] requires-python = ">=3.8" ``` ```toml [project] requires-python = ">=3.10" ``` -------------------------------- ### Error Handling - Example Source: https://github.com/workos/workos-python/blob/main/README.md Catch specific WorkOS API errors like NotFoundError and RateLimitExceededError. ```python from workos._errors import NotFoundError, RateLimitExceededError try: client.organizations.get_organization("org_nonexistent") except NotFoundError as e: print(f"Not found: {e.message}") print(f"Request ID: {e.request_id}") except RateLimitExceededError as e: print(f"Retry after: {e.retry_after} seconds") ``` -------------------------------- ### `portal` became `admin_portal` Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Demonstrates the renaming of the `portal` attribute to `admin_portal` and the change in the `generate_link` argument from `organization_id` to `organization`. ```python link = client.portal.generate_link( organization_id="org_123", intent="sso", ) ``` ```python link = client.admin_portal.generate_link( organization="org_123", intent="sso", ) ``` -------------------------------- ### Models are no longer Pydantic models Source: https://github.com/workos/workos-python/blob/main/docs/V6_MIGRATION_GUIDE.md Compares the model handling in v5 using Pydantic APIs with v6 using `from_dict()` and `to_dict()`. ```python from workos.types.audit_logs.audit_log_event import AuditLogEvent event = AuditLogEvent.model_validate(payload) body = event.model_dump() ``` ```python from workos.audit_logs.models import AuditLogEvent event = AuditLogEvent.from_dict(payload) body = event.to_dict() ``` -------------------------------- ### Pagination - Single Page Operations Source: https://github.com/workos/workos-python/blob/main/README.md Work with a single page of results, accessing data, checking for more pages, and getting the cursor for the next page. ```python # Or work with a single page page = client.user_management.list_users(limit=10) print(page.data) # List of items on this page print(page.has_more()) # Whether more pages exist print(page.after) # Cursor for the next page ``` -------------------------------- ### Build and upload to PyPI Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Builds distribution packages and uploads them to PyPI using a script. ```bash bash scripts/build_and_upload_dist.sh ``` -------------------------------- ### Build distribution packages Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Builds source distribution (sdist) and wheel packages. ```bash uv build --sdist --wheel ``` -------------------------------- ### Run linting using nox Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs linting checks using the nox lint session. ```bash uv run nox -s lint ``` -------------------------------- ### List all available nox sessions Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Lists all available nox sessions. ```bash uv run nox -l ``` -------------------------------- ### Pagination - Auto-Iteration Source: https://github.com/workos/workos-python/blob/main/README.md Iterate through all pages of users automatically using auto_paging_iter. ```python # Iterate through all pages automatically for user in client.user_management.list_users().auto_paging_iter(): print(user.email) ``` -------------------------------- ### Recreate virtual environments Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script to recreate virtual environments. ```bash ./scripts/test.sh --fresh ``` -------------------------------- ### Run tests on all Python versions with nox Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs tests on all supported Python versions using the nox session. ```bash uv run nox ``` -------------------------------- ### Run tests with coverage using nox Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs tests with coverage reporting using the nox coverage session. ```bash uv run nox -s coverage ``` -------------------------------- ### Run all CI checks using nox Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs all CI checks using the nox ci session. ```bash uv run nox -s ci ``` -------------------------------- ### Run all tests on current Python Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs all tests using pytest on the current Python environment. ```bash uv run pytest ``` -------------------------------- ### Run type checking using nox Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs type checking using the nox typecheck session. ```bash uv run nox -s typecheck ``` -------------------------------- ### Type checking Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Performs type checking using pyright. ```bash uv run pyright ``` -------------------------------- ### Run tests with coverage Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script to run tests with coverage reporting on all versions. ```bash ./scripts/test.sh --coverage ``` -------------------------------- ### Run tests on all Python versions Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script to run tests on all supported Python versions. ```bash ./scripts/test.sh ``` -------------------------------- ### Run tests on a specific Python version with nox Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs tests on a specific Python version using a nox session (e.g., tests-3.12). ```bash uv run nox -s tests-3.12 ``` -------------------------------- ### Run full CI checks Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script to perform full CI checks, including linting, type checking, and tests. ```bash ./scripts/test.sh --ci ``` -------------------------------- ### Format code Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Formats the code in the current directory using ruff format. ```bash uv run ruff format . ``` -------------------------------- ### Run tests with coverage Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs tests and generates coverage reports using pytest --cov. ```bash uv run pytest --cov=workos ``` -------------------------------- ### Per-Request Options Source: https://github.com/workos/workos-python/blob/main/README.md Override default request options on a per-call basis, including timeout, retries, custom headers, idempotency keys, and base URL. ```python result = client.organizations.list_organizations( request_options={ "timeout": 10, "max_retries": 5, "extra_headers": {"X-Custom": "value"}, "idempotency_key": "my-key", "base_url": "https://staging.workos.com/", } ) ``` -------------------------------- ### Run tests on multiple Python versions Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script to run tests on specified Python versions (e.g., 3.11 and 3.12). ```bash ./scripts/test.sh 3.11 3.12 ``` -------------------------------- ### Check formatting Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Checks code formatting without making changes using ruff format --check. ```bash uv run ruff format --check . ``` -------------------------------- ### Run tests on a specific Python version Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script to run tests on a specific Python version (e.g., 3.12). ```bash ./scripts/test.sh 3.12 ``` -------------------------------- ### Run tests matching a pattern Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs tests that match a specific pattern using pytest. ```bash uv run pytest -k "test_name" ``` -------------------------------- ### Run specific test file Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Runs tests from a specific file using pytest. ```bash uv run pytest tests/test_sso.py ``` -------------------------------- ### Pass pytest arguments Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Executes the test script and passes arguments to pytest (e.g., filtering tests). ```bash ./scripts/test.sh 3.12 -- -k "test_sso" -v ``` -------------------------------- ### Lint code Source: https://github.com/workos/workos-python/blob/main/CLAUDE.md Lints the code in the current directory using ruff check. ```bash uv run ruff check . ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.