~/talk

How you can benefit from type hints

Talkat EuroPython 2015 · 2015-07-20..07-26· [python, typescript]
links:none on file
slides:none on file

PEP 484 adds optional type hints to Python 3 and the claim is concrete: simple annotations let tools catch real bugs (ElementTree code that passes bytes where str and an illegal indexed iterator), with mypy and PyCharm reporting the errors (PyCharm underlines, mypy prints messages). PyCharm 4.5 has partial support and 5 aims for full support. Use type stubs (.pyi) for Python 2 or third‑party libs, and annotate public APIs with simple types first.

AI-written summary · about

  1. 0:00Intro
  2. 1:17What This Talk is About
  3. 1:57Quick Poll
  4. 2:36Type Hints Used to Be Informal • An example from the standard library
  5. 3:06PEP 484: Type Hints . Based on function annotations, Python 3.5 - Explicit is better than implicit
  6. 3:40The Main Benefit • Improved readability for both humans and tools • Documentation - More compact and easier to grasp than lengthy native
  7. 4:34The Tools
  8. 5:49The Example: ElementTree
  9. 7:17Exceptions
  10. 7:43Add Type Hints • Start with a few function annotations
  11. 8:18Type Checking
  12. 8:47Let's Annotate ElementTree's API - Most type hints are simple
  13. 9:56Type Inference • Tools can infer types in some cases Follow assignments to variables Return types of local functions
  14. 13:49Code Completion • Context-sensitive code completion
  15. 15:58Docs with Type Hints • From the docstring using the Sphinx autodoc extension
  16. 17:25Type Hints for Your Public APIs
  17. 19:26From Simple to Complex
  18. 20:20Liberal vs Conservative
  19. 21:54Type 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. 23:16Python Stubs
  21. 26:21Available Type Hints
  22. 27:22Try Type Hints!
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.