Make FastAPI an optional dependency #30
Merged
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.
Fixes #29
The current setup forces users to install the full
fastapi
package, but they may only want to usefastapi-slim
. In order to allow for that, here I makefastapi
an optional dependency and includefastapi-slim
the same way, so that users can install either of them using eitherfastapi-injector[standard]
orfastapi-injector[slim]
.With this approach we cannot directly enforce a minimum version for our FastAPI needs, but I think Poetry helps us there as it analyses optionals too when resolving dependencies. In any case, this seems to be a more generally adopted setup, e.g. the OpenTelemetry FastAPI instrumentation package.
This new setup also relies on having
fastapi-slim
on both the main dependency list (as an optional extra) and in the dev group for testing. Not sure if there's a better way to reuse just 1 value...