dmontagu / fastapi-utils

Reusable utilities for FastAPI
MIT License
1.94k stars 166 forks source link

[FEATURE] Make sqlalchemy an optional dependency #228

Closed johnthagen closed 5 months ago

johnthagen commented 3 years ago

Is your feature request related to a problem? Please describe.

We use fastapi_utils.InferringRouter on a lot of projects to enable more natural use of type annotations within FastAPI. On some of these projects, there is no database usage at all or even a different database type all together, such as MongoDB.

We'd like to avoid the need of installing sqlalchemy (and its dependency greenlet) in these situations, which makes the Docker images larger and is one more package we need to track for updates and audit.

Describe the solution you'd like

Be able to install fastapi-utils in two ways:

$ pip install fastapi-utils
# This depends only on fastapi and pydantic
$ pip install fastapi[sqlalchemy]
# This additionally installs the extra-requires sqlalchemy

Additional context

In Poetry, use the extras keyword to accomplish this: https://python-poetry.org/docs/pyproject/#extras

Setuptools docs on optional dependencies: https://setuptools.readthedocs.io/en/latest/userguide/dependency_management.html#optional-dependencies

yuval9313 commented 3 years ago

Hey, It is fixed in one of the forks, You are welcome to give it a try

flopberry commented 3 years ago

Hey, It is fixed in one of the forks, You are welcome to give it a try

better make pull request for this feature. I'm also want for this feature but i dont want to install fork instead of this package

ghandic commented 2 years ago

+1

yuval9313 commented 5 months ago

Done in version 0.6.0! (via #291 )