feat!: Generate the Python SDK via the OpenAPI spec#604
Open
gjtorikian wants to merge 27 commits intonext-majorfrom
Open
feat!: Generate the Python SDK via the OpenAPI spec#604gjtorikian wants to merge 27 commits intonext-majorfrom
gjtorikian wants to merge 27 commits intonext-majorfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace mypy with pyright as the primary type checker. pyright is faster, catches more real bugs (better type narrowing, generic inference, union handling), and is the industry standard for production Python SDKs (used by OpenAI, Anthropic, Stripe). - Replace mypy with pyright in noxfile.py (typecheck + ci sessions) - Swap mypy for pyright in type_check dependency group - Remove [tool.mypy] config section - Add [tool.pyright] with typeCheckingMode = "strict" - Update uv.lock The generated SDK passes pyright strict with 0 errors across 374 files. This also addresses #600 (SsoProviderType enum removal) — the emitter generates all spec enums as str/Enum classes, restoring attribute access (e.g., EnumName.VALUE) that was lost when v5 switched to Literal type aliases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add pyrightconfig.json to configure pyright for this codebase - Fix test type errors with proper annotations and constructors - Fix dead assertions in test_audit_logs.py Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…rning Future pytest-asyncio versions will default async fixture loop scope to "function". Set it explicitly to avoid surprises on upgrade. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Delete the entire legacy stack that the generated code replaces: - All 10 _compat.py bridge files - All handwritten service modules (sso.py, connect.py, etc.) - Old client.py, async_client.py, _base_client.py, _client_configuration.py - Entire types/ directory (~170 files of Pydantic models) - typing/ directory (legacy type helpers) - utils/ directory (legacy HTTP client, request helpers) - exceptions.py (replaced by _errors.py) - All legacy test files and fixtures The generated _resource.py + _client.py + models/ are now the sole implementation. Update __init__.py to export from the generated _client.py. Add new conftest.py with workos/async_workos fixtures for the generated test suite. 436 tests pass, 0 failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add all auto-generated resource modules, models, types, and tests - Add verify_event/verify_header back to Webhooks as @oagen-ignore methods - Add list_connections/get_connection/delete_connection to SSO as @oagen-ignore methods - Rename organizations update_organization→update, delete_organization→delete - Fix docstring exception names (*Error→*Exception) across all resource files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerated from updated emitter with: - Audit log exports: exports/export -> create_export/get_export - Authorization role permissions: unwieldy names replaced with set_organization_role_permissions, add_organization_role_permission, etc. - Default request timeout restored to 30s (was 25s) - Event model hand-maintained via oagen-ignore with id, event, data, created_at fields (emitter produces empty placeholder for oneOf unions) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerated from updated emitter that no longer emits unnecessary `pass` in models with zero fields, fixing ruff format CI failure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The generated Event stub is now replaced by the @oagen-ignore block version, eliminating the F811 duplicate class definition lint error. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Regenerated from updated oagen core (top-level @oagen-ignore replacement) and emitters (skip fixtures/tests for empty discriminated union models). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Restores `from workos.exceptions import ...` and `from workos.types.<service> import ...` import paths. Updates V6 migration guide to remove these as breaking changes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This branch moves the Python SDK from the old handwritten surface to the OpenAPI-generated client surface, with a small set of targeted aliases kept where they still help. The result is a much larger API, more consistent resource naming, better typed request and error handling, and a cleaner package layout for the next major release.
Removed
Handwritten compatibility internals
src/workos/_base_client.pysrc/workos/_client_configuration.pysrc/workos/client.pysrc/workos/async_client.pysrc/workos/exceptions.py.src/workos/types/tree and its broad re-export surface.Flat handwritten resource modules
src/workos/api_keys.pysrc/workos/audit_logs.pysrc/workos/authorization.pysrc/workos/connect.pysrc/workos/directory_sync.pysrc/workos/organizations.pysrc/workos/portal.pysrc/workos/user_management.pyOld tooling and model assumptions
pydanticfrom the runtime dependencies;@dataclassis now used instead.mypyas the primary type checker in favor ofpyright.WorkOSListResource-style pagination surface.Added
Generated sync and async clients
WorkOSClientandAsyncWorkOSClientas the main SDK entrypoints.WorkOSandAsyncWorkOSaliases for ergonomics.httpxsync/async clientsRequestOptionsGenerated resource packages and models
admin_portalapplicationsapplication_client_secretsconnectionsdirectoriesdirectory_groupsdirectory_usersfeature_flagsmulti_factor_authpermissionsradarworkos_connectfrom_dict()/to_dict()behavior.SyncPageAsyncPageBetter runtime error handling
src/workos/_errors.py.status_code,message,request_id,raw_body,request_url, andrequest_method.WorkOSTimeoutExceptionWorkOSConnectionExceptionCoverage and maintenance improvements
pyrightconfig.json.pytest-httpxfor HTTP client testing.Changed
Public API shape
client.connectbecomesclient.applicationsandclient.application_client_secretsclient.directory_syncbecomesclient.directories,client.directory_groups, andclient.directory_usersclient.portalbecomesclient.admin_portalWorkOS/AsyncWorkOSclient.mfaas an alias forclient.multi_factor_authclient.user_management.load_sealed_session(...)Client configuration expectations
3.10+.api_keyorclient_id, and only raises if neither is configured.client_idat call time, via constructor configuration, or throughWORKOS_CLIENT_ID.Model behavior
model_validate(),model_dump(), or other Pydantic behaviors now needs to move to the generated dataclass-style API.workos.<resource>.modelspackages rather thanworkos.types.*.Development workflow
mypytopyright --strict.Migration Notes
Biggest user-facing updates
workos, notworkos.client/workos.async_client.connect,portal, anddirectory_sync.client_iddefaults and either pass it explicitly or configure it on the client / environment.max_retries=0.What should feel familiar