Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make FastAPI an optional dependency #30

Merged
merged 2 commits into from
Jun 4, 2024
Merged

Conversation

hasier
Copy link
Contributor

@hasier hasier commented Jun 4, 2024

Fixes #29

The current setup forces users to install the full fastapi package, but they may only want to use fastapi-slim. In order to allow for that, here I make fastapi an optional dependency and include fastapi-slim the same way, so that users can install either of them using either fastapi-injector[standard] or fastapi-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...

pyproject.toml Show resolved Hide resolved
@matyasrichter
Copy link
Owner

LGTM! Could you please also add a mention about this to the README? Just a quick note in the "Installation" section.

@hasier
Copy link
Contributor Author

hasier commented Jun 4, 2024

LGTM! Could you please also add a mention about this to the README? Just a quick note in the "Installation" section.

Makes sense! Something like this? 064edcc Or would you prefer to directly mention the extras and skip the "plain" install?

@matyasrichter
Copy link
Owner

Perfect! Thanks for the PR.

@matyasrichter matyasrichter merged commit 94452bb into matyasrichter:main Jun 4, 2024
6 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.

FastAPI dependency makes difficult to use new fastapi-slim
2 participants