sethmlarson.dev · Saved

Tests aren’t enough: Case study after adding type hints to urllib3 — sethmlarson.dev

sethmlarson.dev/blog/2021-10-18/tests-arent-enough-case-study-after-adding-types-to-urllib3

What Jamie wrote

The debate over type safety in loosely-typed languages like Python has raged for decades. This case study from the maintainers of urllib3 is a good argument for making the investment.

When we originally started this journey our primary goal was to provide a good experience for users who wanted to use type checking tools with urllib3. We weren’t expecting to find and fix many defects.

After all, urllib3 has over 1800 test cases, 100% test line coverage, and is likely some of the most pervasive third-party Python code in the solar system.

Despite all of the above, the inclusion of type checking to our CI has yielded many improvements to our code that likely wouldn't have been discovered otherwise. For this reason we recommend projects evaluate adding type hints and strict type checking to their development workflow instead of relying on testing alone.

The "What we learned" section is particularly good. 🤔

Same host · 2 links from sethmlarson.dev

Saved the same week · 17 links that week

Everything saved in October 2021