DEV Community


Posted on

FastAPI Day 1: Type Hints

Hey there 👋! Today I am starting my day one with FastAPI programming. I have very little knowledge about Python and Django so, I think this is the good time for me to start.

Today I learnt about Type Hints,
Type Hints are nothing but defining the data types of the variables during the declaration. So that we will have required suggestions (Ctrl+Space) from the IDE like VS Code, Sublime text, etc.

suggestions when declaring variable without types hints:
Image description

suggestions when declaring variable with types hints:
Image description

Type Hints can be used for standard data types like int, str, float, bool, byte. In order to use the generic data types like dict, list, tuple, set we have to import typing module in our code.

from typing import List, Set, Tuple, Dict
Enter fullscreen mode Exit fullscreen mode

Top comments (0)