This article lives in:
In very short
This is because we all, as the Python community, define their future. To help us and to help others. From the Core Developers making Python itself to the new developers that started learning Python this month.
And as long as these tools are helping us all solve problems, help ourselves, help others, and be more efficient and productive, we all will keep them working and improving.
And that’s what we are all doing. 🤓🚀
You might have heard not long ago about PEP 563, PEP 649, and some changes that could affect Pydantic and FastAPI in the future.
If you read about it, I wouldn’t expect you to understand what all that meant. I didn’t fully understand it until I spent hours reading all the related content and doing multiple experiments.
It might have worried you and maybe confuse you a bit.
Now there’s nothing to be worried about. But still, here I want to help clarify all that and give you a bit more context.
Brace yourself, you are about to learn a bit more about how Python works, how FastAPI and Pydantic work, how type annotations work, and more. 👇
Start with a basic FastAPI app
FastAPI is based on Pydantic. Let’s see a simple example using them both.
Imagine that we have a file
./main.py with the following code:
from typing import Optionalimport uvicorn
from fastapi import FastAPI
from pydantic import BaseModel
description: Optional[str] = None
app = FastAPI()@app.post("/items/")
def create_item(item: Item):
if __name__ == "__main__":
You could run this example and start the API application with:
$ python ./main.pyINFO: Started server process 
INFO: Waiting for application startup.