Skip to content

Conversation

stacurry
Copy link
Contributor

@stacurry stacurry commented Oct 6, 2025

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.

[X] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@linear
Copy link

linear bot commented Oct 6, 2025

@stacurry stacurry marked this pull request as ready for review October 6, 2025 22:26
@stacurry stacurry requested a review from a team as a code owner October 6, 2025 22:26
@stacurry stacurry requested a review from nave91 October 6, 2025 22:26
Copy link
Contributor

@greptile-apps greptile-apps bot left a 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"
Loading

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@stacurry stacurry requested a review from a team October 11, 2025 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants