You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CLAUDE.md
+48-33Lines changed: 48 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,10 @@
2
2
3
3
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
4
5
+
## Code Generation
6
+
7
+
Most of the SDK is **auto-generated** by `oagen` (an internal OpenAPI code generator). Generated files begin with `# This file is auto-generated by oagen. Do not edit.` Hand-maintained code is fenced with `@oagen-ignore-start` / `@oagen-ignore-end` markers (e.g., `session.py`, `passwordless.py`, `vault.py`).
8
+
5
9
## Development Commands
6
10
7
11
### Installation and Setup
@@ -16,7 +20,7 @@ uv sync --locked --dev # Install package in development mode with dev dependenci
16
20
uv run ruff format .# Format code
17
21
uv run ruff format --check .# Check formatting without making changes
18
22
uv run ruff check .# Lint code
19
-
uv run mypy # Type checking
23
+
uv run pyright# Type checking
20
24
```
21
25
22
26
### Testing
@@ -69,50 +73,61 @@ bash scripts/build_and_upload_dist.sh # Build and upload to PyPI
69
73
70
74
The SDK provides both synchronous and asynchronous clients:
71
75
72
-
-`WorkOSClient` (sync) and `AsyncWorkOSClient` (async) are the main entry points
73
-
- Both inherit from `BaseClient` which handles configuration and module initialization
74
-
- Each feature area (SSO, Directory Sync, etc.) has dedicated module classes
75
-
- HTTP clients (`SyncHTTPClient`/`AsyncHTTPClient`) handle the actual API communication
76
+
-`WorkOS` (sync) and `AsyncWorkOS` (async) are the main entry points (exported from `workos/__init__.py`)
77
+
- Both inherit from `_BaseWorkOS` (in `workos/_client.py`) which handles configuration, HTTP transport, retry logic, and error mapping
78
+
- Each feature area (SSO, Organizations, etc.) is exposed as a `@functools.cached_property` on the client for lazy loading
79
+
- Complex feature areas use namespace classes (e.g., `UserManagementNamespace`, `OrganizationsNamespace`) to group sub-resources
-**Module class** (e.g., `SSO`) - main API interface
82
-
-**Types directory** (e.g., `workos/types/sso/`) - Pydantic models for API objects
83
-
-**Tests** (e.g., `tests/test_sso.py`) - comprehensive test coverage
96
+
Resource classes take a `WorkOS` or `AsyncWorkOS` client reference and call `self._client.request()` or `self._client.request_page()` for paginated endpoints.
84
97
85
98
### Type System
86
99
87
-
- All models inherit from `WorkOSModel` (extends Pydantic `BaseModel`)
88
-
- Strict typing with mypy enforcement (`strict = True` in mypy.ini)
89
-
- Support for both sync and async operations via `SyncOrAsync` typing
100
+
- All models use `@dataclass(slots=True)` — **not** Pydantic
101
+
- Each model implements `from_dict(cls, data) -> Self` for deserialization and `to_dict() -> Dict` for serialization
102
+
- The `Deserializable` protocol in `workos/_types.py` defines the `from_dict` contract
103
+
-`RequestOptions` (a `TypedDict`) allows per-call overrides for headers, timeout, retries, etc.
104
+
- Type checking uses **pyright** (configured in `pyrightconfig.json`)
90
105
91
-
### Testing Framework
106
+
### Pagination
92
107
93
-
-Uses pytest with custom fixtures for mocking HTTP clients
94
-
-`@pytest.mark.sync_and_async()`decorator runs tests for both sync/async variants
95
-
-Comprehensive fixtures in `conftest.py` for HTTP mocking and pagination testing
96
-
-Test utilities in `tests/utils/` for common patterns
108
+
-`SyncPage[T]` and `AsyncPage[T]` dataclasses in `workos/_pagination.py` represent paginated results
0 commit comments