Skip to content

Check for Engin-injected parameter using the dependency function name#65

Merged
invokermain merged 2 commits into
invokermain:mainfrom
karvozavr:feature/fastapi-depends-no-magic-field
Nov 29, 2025
Merged

Check for Engin-injected parameter using the dependency function name#65
invokermain merged 2 commits into
invokermain:mainfrom
karvozavr:feature/fastapi-depends-no-magic-field

Conversation

@karvozavr
Copy link
Copy Markdown
Contributor

Compatibility fix for FastAPI>=0.121.3

https://fastapi.tiangolo.com/release-notes/#01213

Due to the recent FastAPI release making Depends object a dataclass, using custom Depends.__engin__ attribute is no longer possible.

The suggested fix leverages an approach which depends less on the internals of the FastAPI, and interacts with its public API — it checks for Depends.dependency function name (that is created by engin).

The only potential issue, is someone using the same dependency function name __inner_engin_dependency__, which is highly unlikely.

@invokermain invokermain force-pushed the feature/fastapi-depends-no-magic-field branch from 8d993a9 to f8a26a2 Compare November 24, 2025 12:46
@codecov
Copy link
Copy Markdown

codecov Bot commented Nov 24, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.96%. Comparing base (0a653fd) to head (b86d90b).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #65      +/-   ##
==========================================
- Coverage   90.97%   90.96%   -0.02%     
==========================================
  Files          19       19              
  Lines        1197     1195       -2     
  Branches      161      161              
==========================================
- Hits         1089     1087       -2     
  Misses         67       67              
  Partials       41       41              
Flag Coverage Δ
macos-latest 90.04% <100.00%> (-0.02%) ⬇️
py3.10 90.54% <100.00%> (-0.02%) ⬇️
py3.11 90.54% <100.00%> (-0.02%) ⬇️
py3.12 90.54% <100.00%> (-0.02%) ⬇️
py3.13 90.54% <100.00%> (-0.02%) ⬇️
py3.14 90.55% <100.00%> (-0.02%) ⬇️
ubuntu-latest 90.04% <100.00%> (-0.02%) ⬇️
windows-latest 90.37% <100.00%> (-0.02%) ⬇️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@invokermain
Copy link
Copy Markdown
Owner

Looks good! Thanks for the fix.

I think it would be good to add a comment above the __inner_engin_dependency__ func explaining the name is special. I had already forgotten as I originally assumed the __engin__ attribute was used for much more than just powering the graph.

If you want you can also update the CHANGELOG.md or I can do it later. I will probably add an improvement to the engin check error message and release those two changes together.

@karvozavr
Copy link
Copy Markdown
Contributor Author

@invokermain, I have added a CHANGELOG.md entry.

Please let me know what's the planned change to the engin check error message, maybe I could address it as well?

@invokermain
Copy link
Copy Markdown
Owner

See pull request here: #67. I've only added a failing test case so far.

@invokermain invokermain merged commit 6fc1f7a into invokermain:main Nov 29, 2025
20 checks passed
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.

2 participants