DEV Community

nixcodes
nixcodes

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

Sentry image

See why 4M developers consider Sentry, โ€œnot bad.โ€

Fixing code doesnโ€™t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

๐Ÿ‘‹ Kindness is contagious

Please leave a โค๏ธ or a friendly comment on this post if you found it helpful!

Okay