Главная
Study mode:
on
1
Intro
2
What This Talk is About
3
Quick Poll
4
Type Hints Used to Be Informal • An example from the standard library
5
PEP 484: Type Hints . Based on function annotations, Python 3.5 - Explicit is better than implicit
6
The Main Benefit • Improved readability for both humans and tools • Documentation - More compact and easier to grasp than lengthy native
7
The Tools
8
The Example: ElementTree
9
Exceptions
10
Add Type Hints • Start with a few function annotations
11
Type Checking
12
Let's Annotate ElementTree's API - Most type hints are simple
13
Type Inference • Tools can infer types in some cases Follow assignments to variables Return types of local functions
14
Code Completion • Context-sensitive code completion
15
Docs with Type Hints • From the docstring using the Sphinx autodoc extension
16
Type Hints for Your Public APIs
17
From Simple to Complex
18
Liberal vs Conservative
19
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
20
Python Stubs
21
Available Type Hints
22
Try Type Hints!
Description:
Discover the benefits of type hints in Python through this informative conference talk from EuroPython 2015. Explore how PEP 484 introduces type hints for Python 3, enhancing code readability for both humans and tools. Learn practical examples of type hint usage, their value in public APIs, and how they can lead to better and safer outcomes. Gain insights into using simple class types and built-in collection types for public APIs, and understand the advantages of type hinting stubs for third-party libraries. Delve into topics such as informal type hints, function annotations, type checking, type inference, code completion, and documentation improvements. Examine the ElementTree API as a practical example, and explore the spectrum from simple to complex type hints. Understand the liberal vs. conservative approaches to type hinting, and learn how to implement type hints in your own code using Python 3 function annotations. Discover available type hints and leave inspired to try them in your Python projects. Read more

How You Can Benefit from Type Hints

EuroPython Conference
Add to list