How You Can Benefit from Type Hints
Offered By: EuroPython Conference via YouTube
Course Description
Overview
Syllabus
Intro
What This Talk is About
Quick Poll
Type Hints Used to Be Informal • An example from the standard library
PEP 484: Type Hints . Based on function annotations, Python 3.5 - Explicit is better than implicit
The Main Benefit • Improved readability for both humans and tools • Documentation - More compact and easier to grasp than lengthy native
The Tools
The Example: ElementTree
Exceptions
Add Type Hints • Start with a few function annotations
Type Checking
Let's Annotate ElementTree's API - Most type hints are simple
Type Inference • Tools can infer types in some cases Follow assignments to variables Return types of local functions
Code Completion • Context-sensitive code completion
Docs with Type Hints • From the docstring using the Sphinx autodoc extension
Type Hints for Your Public APIs
From Simple to Complex
Liberal vs Conservative
Type Hints in Your Code • Type hints in Python 3 function annotations It's enough to pip install a library • Compatible with Python 3.5
Python Stubs
Available Type Hints
Try Type Hints!
Taught by
EuroPython Conference
Related Courses
A Brief History of Data StorageEuroPython Conference via YouTube Breaking the Stereotype - Evolution & Persistence of Gender Bias in Tech
EuroPython Conference via YouTube We Can Get More from Spatial, GIS, and Public Domain Datasets
EuroPython Conference via YouTube Using NLP to Detect Knots in Protein Structures
EuroPython Conference via YouTube The Challenges of Doing Infra-As-Code Without "The Cloud"
EuroPython Conference via YouTube