Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CLI apps with Typer - Python type annotations and shell completion
Search
Sebastián Ramírez
October 10, 2022
Technology
0
300
CLI apps with Typer - Python type annotations and shell completion
Sebastián Ramírez
October 10, 2022
Tweet
Share
More Decks by Sebastián Ramírez
See All by Sebastián Ramírez
Modern Python through FastAPI and friends - PyCon Sweden
tiangolo
0
29
Await for it: mixing async and blocking code - PyCon MEA - Dubai
tiangolo
0
12
Intro to FastAPI: Tips and Tricks for ML
tiangolo
1
250
Modern Python through FastAPI and friends - PyCon MEA - Dubai
tiangolo
0
860
Software de Colombia para el mundo
tiangolo
1
1.6k
Modern Python through FastAPI and friends - PyCon Indonesia
tiangolo
0
470
Modern Python through FastAPI and friends - Dubai - AI Everything - Gitex
tiangolo
0
83
Modern Python through FastAPI and friends - PyCon India
tiangolo
1
260
Haz un servicio de ML fácilmente con FastAPI
tiangolo
0
450
Other Decks in Technology
See All in Technology
VSCodeの拡張機能を作っている話
ebarakazuhiro
1
760
リテール金融(キャッシュレス・ネット銀行・ネット証券)の競争環境と経済圏
8maki
0
1.5k
2024春 注目のWeb系 OSS & SaaS 3選
makies
0
170
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
4
37k
AWSに詳しくない人でも始められるコスト最適化ガイド
yuhta28
2
280
アクセス制御にまつわる改善 / Improving access control
itkq
0
580
Autonomous Database Cloud 技術詳細 / adb-s_technical_detail_jp
oracle4engineer
PRO
14
35k
R3のコードから見る実践LINQ実装最適化・コンカレントプログラミング実例
neuecc
3
1.8k
障害対応をちょっとずつよくしていくための 演習の作りかた
heleeen
1
1.5k
【基本】データベース設計
oracle4engineer
PRO
2
100
Babylon.js JAPAN活動紹介 (2024/4)
limes2018
1
100
Amplify 🩷 Bedrock 〜生成AI入門〜
minorun365
PRO
7
360
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
267
39k
GraphQLとの向き合い方2022年版
quramy
33
12k
Visualization
eitanlees
137
14k
Facilitating Awesome Meetings
lara
43
5.6k
Stop Working from a Prison Cell
hatefulcrawdad
267
19k
Six Lessons from altMBA
skipperchong
22
3k
Automating Front-end Workflow
addyosmani
1357
200k
Done Done
chrislema
178
15k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Testing 201, or: Great Expectations
jmmastey
29
6.4k
Building Applications with DynamoDB
mza
88
5.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
Transcript
CLI apps with type annotations and shell completion
Who am I? Sebastián Ramírez github.com/tiangolo linkedin.com/in/tiangolo twitter.com/tiangolo tiangolo.com Berlin,
Germany Senior Staff Software Engineer at I created: ➕ External Consultant for other teams
About Typer • 8K+ GitHub stars • FastAPI's little sibling
• Powered by Click @tiangolo
Command Line Interfaces (CLI) or Terminals @tiangolo • Text based
• You send program and parameters • Computer goes beep boop • Maybe output • Examples of CLI apps: git, ssh, pip
Simple function with type annotations @tiangolo
Simple function with type annotations @tiangolo
Why type annotations - error checks @tiangolo
Why type annotations - completion @tiangolo
Simple function with type annotations - recap @tiangolo
Simple scripts with Typer @tiangolo
Simple scripts - required arguments @tiangolo
Simple scripts with Typer - main block @tiangolo
Simple scripts - required arguments missing @tiangolo
Simple scripts with --help @tiangolo
Simple scripts - options @tiangolo
Simple scripts - invalid data @tiangolo
Simple scripts - more help @tiangolo
Simple scripts - more help in the terminal @tiangolo
Simple scripts - help for parameters @tiangolo
Simple scripts - help for parameters in the terminal @tiangolo
A Typer app @tiangolo
A Typer app - app object @tiangolo
A Typer app - decorator @tiangolo
A Typer app - call the app @tiangolo
A Typer app - supergreet @tiangolo
Install completion @tiangolo ✨ Works for everything: • Zsh •
Bash • Fish • PowerShell
Use completion @tiangolo
Use completion @tiangolo
Use completion @tiangolo
Use completion @tiangolo
Use completion @tiangolo
Completion @tiangolo 🧙 Works by default and can be used
for: • Deeply nested commands • CLI Options and CLI Arguments • Custom data (e.g. remote, from an API) • etc.
Commands @tiangolo
Commands - hi @tiangolo
Commands - bye @tiangolo
Help with commands @tiangolo
Commands - hi again @tiangolo
Commands --help for hi @tiangolo
Command hi in terminal @tiangolo
Commands - bye @tiangolo
Commands --help for bye @tiangolo
More Typer features @tiangolo • 🥅 Boolean flags • ❓
Prompts • 🔒 Ask passwords • 🚀 Launch apps (e.g. a browser) • ✅ Easy testing • ✨ More…
Thank you! Sebastián Ramírez tiangolo.com typer.tiangolo.com github.com/tiangolo linkedin.com/in/tiangolo twitter.com/tiangolo