Skip to content

Conversation

@claythearc
Copy link
Owner

Fixed a bug where using Dict or Mapping type hints with Relationship() would cause infinite recursion. The get_relationship_to() function now properly handles dict/Mapping types by extracting the value type (second type argument), similar to how it handles List types.

Changes:

  • Added handling for dict and Mapping origins in get_relationship_to()
  • Extracts the value type from Dict[K, V] or Mapping[K, V] annotations
  • Added comprehensive tests for Dict relationships with attribute_mapped_collection

This resolves the RecursionError that occurred when defining relationships like: children: Dict[str, Child] = Relationship(...)

🤖 Generated with Claude Code

Fixed a bug where using Dict or Mapping type hints with Relationship()
would cause infinite recursion. The get_relationship_to() function now
properly handles dict/Mapping types by extracting the value type (second
type argument), similar to how it handles List types.

Changes:
- Added handling for dict and Mapping origins in get_relationship_to()
- Extracts the value type from Dict[K, V] or Mapping[K, V] annotations
- Added comprehensive tests for Dict relationships with attribute_mapped_collection

This resolves the RecursionError that occurred when defining relationships
like: children: Dict[str, Child] = Relationship(...)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@claythearc claythearc merged commit 1db2a9a into main Oct 29, 2025
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.

3 participants