pydantic is a missing runtime dependency #276
Replies: 2 comments
-
|
Thanks, good point, I'll look into this. |
Beta Was this translation helpful? Give feedback.
-
|
Ok so while I agree that it's not best practice to depend on a package that is not explicitely installed, I think the case for this specific repo is a bit more nuanced. If we'd add Another potential solution would be to have a conditional import of |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
This statement in the docs https://fastapi.tiangolo.com/fastapi-cli/?h=fastapi+cli#fastapi-cli says:
When you install FastAPI (e.g. with pip install "fastapi[standard]"), it includes a package called fastapi-cli, this package provides the fastapi command in the terminal.Which means that you can run the command
fastapiafter installingfastapi-cliitself. The same applies to this section https://github.com/fastapi/fastapi-cli/tree/0.0.20?tab=readme-ov-file#description.I guess it's not designed to run without the
fastapipackage, but the code itself has pydantic, which is not mentioned in runtime dependencies.pydanticis a missing runtime dependency and is not mentioned here https://github.com/fastapi/fastapi-cli/blob/0.0.20/pyproject.toml#L34-L39, but it's used at runtime here https://github.com/fastapi/fastapi-cli/blob/0.0.20/src/fastapi_cli/cli.py#L6 and here https://github.com/fastapi/fastapi-cli/blob/0.0.20/src/fastapi_cli/config.py#L5.This line of the
fastapicode https://github.com/fastapi/fastapi/blob/master/fastapi/cli.py#L2 says that it directly relies onfastapi_cli.Basically, an entry point
fastapi = fastapi_cli.cli:mainbelongs to thefastapi-clipackage.Operating System
Other
Operating System Details
unix and win platforms
Python Version
py310-py314
Additional Context
If I run
fastapi --helporfastapi --versionwithoutpydantic >=2.0.0in the test environment, I get:Details
But if I add
pydanticto the runtime dependencies, it works fine:Details
Beta Was this translation helpful? Give feedback.
All reactions