Bulletproof Python – Writing fewer tests with a typed code base
- Level:
- intermediate
- Room:
- south hall 2b
- Start:
- Duration:
- 30 minutes
Abstract
A fully typed code base requires less test code to achieve the same level of confidence in its correctness. We'll analyze specific code examples and see how dependent types and exhaustiveness checking make certain classes of tests obsolete.
Description
A type system forms a set of rules that is imposed on a programming language with the goal to avoid invalid operations. Type checking Python code is particularly interesting, because it happens before running the code or the test code. This allows software engineers to perform checks on the source code that otherwise would have to be performed at runtime.
The typing module in the Python standard library provides powerful concepts to provide hints to the type checker. Specifically, we'll look at use cases for NewType, dependent functions, and exhaustiveness checking.
Audience members are expected to be able to read and understand Python code and have a basic understanding of unit testing.