Skip to content

feat: allow overriding CustomField dependencies via dependency_provider#263

Open
anzzyspeaksgit wants to merge 1 commit intoLancetnik:mainfrom
anzzyspeaksgit:fix-issue-176-new
Open

feat: allow overriding CustomField dependencies via dependency_provider#263
anzzyspeaksgit wants to merge 1 commit intoLancetnik:mainfrom
anzzyspeaksgit:fix-issue-176-new

Conversation

@anzzyspeaksgit
Copy link

Summary

This PR adds support for overriding CustomField classes and instances using dependency_provider.override(), addressing #176.

Problem

Closes #176
Currently, users are unable to override CustomFields at runtime using dependency_provider for testing purposes. dependency_provider.override() crashes or has no effect when provided with a CustomField class or instance.

Solution

Modified CallModel._solve and _asolve to intercept evaluations of CustomField and apply mocked overrides from provider.overrides (checked by instance or type).
Updated Provider.override to skip calling build_call_model on CustomField objects to prevent instantiation/signature errors. Type annotations updated to accept CustomField.
Added tests in test_overrides.py to ensure both CustomField classes and specific instances can be safely overridden.

Testing

  • Tests pass locally.
  • Verified both sync/async paths and field=True/False variants.

This PR was created with AI assistance.

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.

Override CustomField dependency

1 participant