feat: Type Registry System & Static/Dynamic Import Modes (v0.2.0)#2
Merged
pyros-projects merged 7 commits intomainfrom Nov 24, 2025
Merged
feat: Type Registry System & Static/Dynamic Import Modes (v0.2.0)#2pyros-projects merged 7 commits intomainfrom
pyros-projects merged 7 commits intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Overview
This PR introduces two major feature sets for wishful v0.2.0:
These features significantly enhance wishful's capabilities for production use cases while maintaining backward compatibility.
✨ What's New
🔷 Type Registry System
Allows users to register complex types (Pydantic models, dataclasses, TypedDict) so the LLM can generate functions that return properly structured data.
Key Features:
@wishful.typedecorator for registering types@wishful.type(output_for="function_name")Example:
🔷 Static vs Dynamic Import Modes
Namespace-based routing for different caching behaviors:
wishful.static.*(Default, Cached)wishful.dynamic.*(Runtime-Aware, Fresh)Example:
🔧 Technical Changes
Core Implementation
Type Registry (
src/wishful/types/)registry.py: TypeRegistry class with serialization for Pydantic/dataclass/TypedDict_build_field_args(): Parses Pydantic v2 metadata list for Field constraintsImport Hook Enhancements (
src/wishful/core/)finder.py: Updated MagicFinder to routestaticvsdynamicnamespacesloader.py: MagicLoader acceptsmodeparameter ("static" or "dynamic")discovery.py: Fetches type schemas and output type bindingsLLM Integration (
src/wishful/llm/)prompts.py: Enhanced to include type definitions in system promptCache Management (
src/wishful/cache/)manager.py: Stripsstatic/dynamicnamespace prefixes from cache pathswishful.static.text→.wishful/text.py)Testing
New Test Coverage:
tests/test_types.py: 30 tests for type registry (Pydantic, dataclass, TypedDict, constraints)tests/test_namespaces.py: 6 tests for static vs dynamic behaviortests/test_discovery.py: 4 additional tests for type schema integrationTest Statistics:
Documentation
Updated:
README.md: Complete rewrite showcasing new featuresAGENTS.md: Comprehensive sync with codebasedocs/CHANGELOG.md: Created for v0.2.0 release notesNew Examples:
examples/07_typed_outputs.py: Showcases type registry with all supported typesexamples/08_dynamic_vs_static.py: Demonstrates namespace differencesexamples/09_context_shenanigans.py: Context discovery and import-site hintsDependencies
Added:
pydantic>=2.12.4: Required for Pydantic v2 type registry supportVersion Bump
pyproject.toml: Version 0.1.6 → 0.2.0🧪 Testing & Validation
Automated Tests
uv run pytest tests/ -v # Result: 83 passed in 0.14s ✅Manual Validation
Backward Compatibility
📊 Impact Assessment
Benefits
✅ Structured Output: Production-ready type-safe code generation
✅ Flexibility: Choose between cached stability vs runtime creativity
✅ Developer Experience: Docstrings influence LLM behavior (e.g., tone, style)
✅ Type Safety: Pydantic constraints actually enforced by LLM
✅ Performance: Static mode = zero latency after first import
Risks & Mitigations
🔍 Code Review Checklist
🚀 Deployment Notes
Post-Merge Actions
git tag v0.2.0uv builduv publishUser Migration
No migration needed - backward compatible. Users can:
@wishful.typewishful.dynamic.*📝 Related Issues
Closes: N/A (feature development)
Relates to: Future work on multi-agent workflows, evaluation frameworks
🙏 Acknowledgments
This feature set evolved from exploring how to make LLM-generated code production-ready:
The Yoda-speak example proved docstrings actually influence LLM behavior in delightful ways. 🎭
🤔 Open Questions for Reviewers
wishful.list_registered_types())?*Ready to merge/home/ai/projects/wishful && git log --oneline main..HEAD All tests green, documentation complete, examples working. ��✨