Skip to content

fix: expose GetSignalsRequest as union alias, not RootModel#143

Closed
bokelley wants to merge 1 commit intomainfrom
bokelley/lansing-v6
Closed

fix: expose GetSignalsRequest as union alias, not RootModel#143
bokelley wants to merge 1 commit intomainfrom
bokelley/lansing-v6

Conversation

@bokelley
Copy link
Contributor

@bokelley bokelley commented Mar 1, 2026

Closes #138

Problem

GetSignalsRequest is generated as RootModel[GetSignalsRequest1 | GetSignalsRequest2]. Pydantic hard-rejects model_config['extra'] on any RootModel subclass at class construction time, breaking the documented pattern of subclassing library types with env-based config:

# This fails with PydanticUserError in 3.6.0+
class MyGetSignalsRequest(LibraryGetSignalsRequest):
    model_config = ConfigDict(extra="forbid")

Fix

Add a plain union alias in aliases.py that shadows the RootModel wrapper in the public API:

# aliases.py
GetSignalsRequest = GetSignalsRequest1 | GetSignalsRequest2

__init__.py now exports this alias instead of the generated RootModel. Consumers can subclass either variant:

class MyGetSignalsRequest(GetSignalsRequest1):
    model_config = ConfigDict(extra="forbid")

Test plan

  • GetSignalsRequest is a types.UnionType, not a RootModel subclass
  • Union contains exactly GetSignalsRequest1 | GetSignalsRequest2
  • Subclassing either variant with custom model_config works without error
  • 654 tests pass

🤖 Generated with Claude Code

Pydantic hard-rejects model_config['extra'] on RootModel subclasses, which
broke the documented pattern of subclassing library types with env-based config.

Adding a plain union alias in aliases.py shadows the generated RootModel wrapper,
restoring the ability for consumers to subclass GetSignalsRequest1 or
GetSignalsRequest2 with custom model_config.

Closes #138

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bokelley bokelley closed this Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GetSignalsRequest as RootModel breaks the library's own inheritance pattern in consumers

1 participant