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
Python Type Hints
Search
José Padilla
March 15, 2018
0
480
Python Type Hints
5min talk on Python Type Hints. Presented at newhaven.io
José Padilla
March 15, 2018
Tweet
Share
More Decks by José Padilla
See All by José Padilla
Python, Government, and Contracts
jpadilla
0
46
Python, Government, and Contracts
jpadilla
0
4.9k
Developer Ergonomics
jpadilla
0
2.1k
DjangoCon - JSON Web Tokens
jpadilla
15
11k
BFTW: The Backend
jpadilla
4
190
eventos
jpadilla
0
150
JWT
jpadilla
2
420
Ember.js + Django
jpadilla
3
2.1k
UPRB Basic Workshop
jpadilla
2
200
Featured
See All Featured
Done Done
chrislema
182
16k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Building an army of robots
kneath
303
45k
Fontdeck: Realign not Redesign
paulrobertlloyd
83
5.4k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.2k
VelocityConf: Rendering Performance Case Studies
addyosmani
328
24k
Writing Fast Ruby
sferik
628
61k
Building a Scalable Design System with Sketch
lauravandoore
462
33k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
BBQ
matthewcrist
87
9.5k
Why Our Code Smells
bkeepers
PRO
336
57k
Transcript
Type Hints
José Padilla
Work Training
Work Open Source
PEP 3107
None
PEP 484
None
no type checking happens at runtime
static analysis refactoring runtime type checking code generation
static analysis refactoring runtime type checking code generation
None
Common built-in types
None
None
None
None
None
None
None
None
None
None
None
None
None
Generics
None
None
mypy
static type checker
$ pip install mypy
$ python app.py
None
$ python app.py f 1 Traceback (most recent call last):
File "app.py", line 12, in <module> print(first(1)) # TypeError File "app.py", line 7, in first return seq[0] TypeError: 'int' object is not subscriptable
$ mypy app.py
$ mypy app.py main.py:12: error: Argument 1 to "first" has
incompatible type "int"; expected "Sequence[<nothing>]"
None
mypy-lang.org
Python will remain a dynamically typed language
Thanks! jpadilla.com twitter.com/@jpadilla_ github.com/jpadilla