Skip to content

Use uncalled-for for dependency injection plumbing#353

Open
chrisguidry wants to merge 4 commits intomainfrom
use-uncalled-for
Open

Use uncalled-for for dependency injection plumbing#353
chrisguidry wants to merge 4 commits intomainfrom
use-uncalled-for

Conversation

@chrisguidry
Copy link
Owner

@chrisguidry chrisguidry commented Feb 25, 2026

Docket's DI engine was extracted into the standalone uncalled-for library. 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.

Closes #352

🤖 Generated with Claude Code

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>
@read-the-docs-community
Copy link

read-the-docs-community bot commented Feb 25, 2026

Documentation build overview

📚 docket | 🛠️ Build #31571613 | 📁 Comparing 583778c against latest (c51bde1)


🔍 Preview build

Show files changed (2 files in total): 📝 2 modified | ➕ 0 added | ➖ 0 deleted
File Status
api-reference/index.html 📝 modified
dependency-injection/index.html 📝 modified

@codecov-commenter
Copy link

codecov-commenter commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c51bde1) to head (583778c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##              main      #353    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           99        99            
  Lines         3098      2969   -129     
  Branches        27        26     -1     
==========================================
- Hits          3098      2969   -129     
Flag Coverage Δ
cli-python-3.10 100.00% <ø> (ø)
cli-python-3.11 100.00% <ø> (ø)
cli-python-3.12 100.00% <ø> (ø)
cli-python-3.13 100.00% <ø> (ø)
cli-python-3.14 100.00% <ø> (ø)
python-3.10 100.00% <100.00%> (ø)
python-3.11 97.89% <100.00%> (-0.10%) ⬇️
python-3.12 100.00% <100.00%> (ø)
python-3.13 100.00% <100.00%> (ø)
python-3.14 100.00% <100.00%> (ø)
windows-python-3.10 100.00% <100.00%> (ø)
windows-python-3.11 97.80% <100.00%> (-0.11%) ⬇️
windows-python-3.12 100.00% <100.00%> (ø)
windows-python-3.13 100.00% <100.00%> (ø)
windows-python-3.14 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/docket/dependencies/__init__.py 100.00% <ø> (ø)
src/docket/dependencies/_base.py 100.00% <100.00%> (ø)
src/docket/dependencies/_concurrency.py 100.00% <ø> (ø)
src/docket/dependencies/_contextual.py 100.00% <100.00%> (ø)
src/docket/dependencies/_cron.py 100.00% <ø> (ø)
src/docket/dependencies/_functional.py 100.00% <100.00%> (ø)
src/docket/dependencies/_perpetual.py 100.00% <ø> (ø)
src/docket/dependencies/_progress.py 100.00% <ø> (ø)
src/docket/dependencies/_resolution.py 100.00% <100.00%> (ø)
src/docket/dependencies/_retry.py 100.00% <ø> (ø)
... and 7 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

chrisguidry and others added 2 commits February 25, 2026 16:39
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>
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.

Spin out Docket's dependency injection system as a separate library

2 participants