-
Notifications
You must be signed in to change notification settings - Fork 21
add locale to user #478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add locale to user #478
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Summary
This PR adds locale support to the WorkOS Python SDK's User Management functionality. The changes enable applications to store and retrieve user language/region preferences by adding an optional `locale` field to the User model and supporting locale updates through the `update_user` method.The implementation follows WorkOS's established patterns for optional user attributes. The User model in workos/types/user_management/user.py
gains a new locale: Optional[str] = None
field, maintaining backward compatibility since it's optional. The update_user
method in both sync and async implementations of UserManagement (workos/user_management.py
) now accepts an optional locale
parameter that gets included in the API request payload.
This change integrates seamlessly with the existing codebase architecture. The User model uses Pydantic for data validation and serialization, and the new field follows the same pattern as other optional user attributes like first_name
and last_name
. The update functionality leverages the existing HTTP client infrastructure and request handling patterns already established in the SDK.
The test coverage ensures the feature works correctly by updating the MockUser fixture to include a default "en-US" locale and adding specific test cases to verify both user retrieval with locale data and locale updates through the API.
Important Files Changed
Changed Files
Filename | Score | Overview |
---|---|---|
workos/types/user_management/user.py | 5/5 | Adds optional locale field to User model following existing patterns |
workos/user_management.py | 5/5 | Adds locale parameter support to update_user methods in both sync/async implementations |
tests/test_user_management.py | 5/5 | Adds comprehensive test coverage for locale field retrieval and updates |
tests/utils/fixtures/mock_user.py | 5/5 | Updates mock user fixture with default "en-US" locale for test consistency |
Confidence score: 5/5
- This PR is safe to merge with minimal risk as it adds optional functionality without breaking existing code
- Score reflects simple, well-tested changes that follow established SDK patterns and maintain backward compatibility
- No files require special attention as all changes are straightforward and properly tested
Sequence Diagram
sequenceDiagram
participant User
participant "Client Application" as Client
participant "WorkOS User Management" as WorkOS
participant "HTTP Client" as HTTP
participant "User Model" as Model
User->>Client: "Update user locale to 'fr-FR'"
Client->>WorkOS: "update_user(user_id, locale='fr-FR')"
WorkOS->>HTTP: "PUT /user_management/users/{user_id}"
Note over HTTP: "Request body includes locale field"
HTTP->>WorkOS: "HTTP 200 OK with updated user data"
WorkOS->>Model: "User.model_validate(response)"
Model->>WorkOS: "User object with locale='fr-FR'"
WorkOS->>Client: "Return updated User object"
Client->>User: "Confirmation: locale updated successfully"
4 files reviewed, no comments
Description
adds locale to the User object, adds support for updating User locale
Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.