Use uncalled-for for dependency injection plumbing#353
Open
chrisguidry wants to merge 4 commits intomainfrom
Open
Use uncalled-for for dependency injection plumbing#353chrisguidry wants to merge 4 commits intomainfrom
chrisguidry wants to merge 4 commits intomainfrom
Conversation
Docket's DI engine was extracted into the standalone `uncalled-for` library (https://pypi.org/project/uncalled-for/). This swaps out all the internal DI plumbing — parameter introspection, dependency resolution, validation, `Depends()`, `Shared`, `SharedContext` — for imports from that package. The public API is unchanged; everything is re-exported from `docket.dependencies` exactly as before. The docket-specific bits (ContextVars, Retry, Perpetual, ConcurrencyLimit, etc.) stay in docket. The three ambient ContextVars (`current_docket`, `current_worker`, `current_execution`) are now module-level variables in `_base.py` rather than class attributes on a custom `Dependency` subclass, so `Dependency` is just a direct re-export of `uncalled_for.Dependency`. Net result: −394 lines, +167 lines across the dependencies package. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Documentation build overview
Show files changed (2 files in total): 📝 2 modified | ➕ 0 added | ➖ 0 deleted
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #353 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 99 99
Lines 3098 2969 -129
Branches 27 26 -1
==========================================
- Hits 3098 2969 -129
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3ea664fa5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
SharedContext no longer needs a docket-specific subclass. The worker now sets current_docket/current_worker ContextVars directly in its own __aenter__, and SharedContext is just a re-export of uncalled_for's. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
FastMCP accesses Dependency.execution.get() to retrieve the current execution context. Now that Dependency comes from uncalled-for and the ContextVars are module-level, patch them back onto the class so existing consumers keep working. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
chrisguidry
added a commit
to PrefectHQ/fastmcp
that referenced
this pull request
Feb 25, 2026
FastMCP vendored a minimal DI engine extracted from Docket (~164 lines) with try/except fallback patterns everywhere. The `uncalled-for` package is a clean, typed extraction of this same system, and since Docket will also depend on it (chrisguidry/docket#353), `uncalled_for.Dependency` becomes the single canonical base class. This deletes the `_vendor/docket_di/` directory, replaces all the try/except import patterns with direct `uncalled_for` imports, and updates the `Dependency.execution` → `current_execution` ContextVar references to match the Docket branch. The `Progress` class now delegates to an internal impl and returns `self` from `__aenter__` (matching Docket's pattern) so that ty's generic resolution works without `type: ignore` suppressions. Temporarily points pydocket at the `use-uncalled-for` branch so both sides can be validated together in CI. 🤖 Generated with Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a note to the dependency injection docs that the DI system is now built on uncalled-for as of 0.18.0, with links to its GitHub and PyPI. Also updates the "Subclassing Dependency" section to show the new module-level ContextVars (current_docket, current_worker, current_execution) instead of the old class-attribute pattern, and adds an example of using the higher-level contextual dependencies instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Docket's DI engine was extracted into the standalone
uncalled-forlibrary. This swaps out all the internal DI plumbing — parameter introspection, dependency resolution, validation,Depends(),Shared,SharedContext— for imports from that package.The public API is unchanged; everything is re-exported from
docket.dependenciesexactly as before. The docket-specific bits (ContextVars, Retry, Perpetual, ConcurrencyLimit, etc.) stay in docket.The three ambient ContextVars (
current_docket,current_worker,current_execution) are now module-level variables in_base.pyrather than class attributes on a customDependencysubclass, soDependencyis just a direct re-export ofuncalled_for.Dependency.Net result: −394 lines, +167 lines across the dependencies package.
Closes #352
🤖 Generated with Claude Code