Tests aren’t enough: Case study after adding type hints to urllib3

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Scout Monitoring - Free Django app performance insights with Scout Monitoring
Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.
www.scoutapm.com
featured
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
  • dactyl-keyboard

    Web generator for dactyl keyboards. (by ibnuda)

    i have a small side project in clojure [1] and i always miss type checking when working on it. not by much because it's a small project but i am tired of iseq is not a function error.

    [1] https://dactyl.siskam.link

  • Scout Monitoring

    Free Django app performance insights with Scout Monitoring. Get Scout setup in minutes, and let us sweat the small stuff. A couple lines in settings.py is all you need to start monitoring your apps. Sign up for our free tier today.

    Scout Monitoring logo
  • typeshed

    Collection of library stubs for Python, with static types

    I agree with all the benefits of mypy cited in this article. For me, most important thing for the long-term health of a codebase is its readability/maintainability, and mypy static typing makes such a huge difference for that in large Python codebases. I'm really excited to see large libraries doing this migration.

    I'll add for folks thinking about this transition that we took a pretty different strategy for converting Zulip to be type-checked: https://blog.zulip.com/2016/10/13/static-types-in-python-oh-...

    The post is from 2016 and thus a bit stale in terms of the names of mypy options and the like, but the incremental approach we took involved only using mypy's native exclude tooling, and might be useful for some projects thinking about doing this transition.

    One particular convention that I think many other projects may find useful is how we do `type: ignore` in comments in the Zulip codebase, which is to have a second comment on the line explaining why we needed a `type: ignore`, like so:

    * # type: ignore[type-var] # https://github.com/python/typeshed/issues/4234

    * # type: ignore[attr-defined] # private member missing from stubs

    * # type: ignore[assignment] # Apparent mypy bug with Optional[int] setter.

    * # type: ignore[misc] # This is an undocumented internal API

    We've find this to be a lot more readable than using the commit message to record why we needed a `type: ignore`, and in particular it makes the work of removing these with time feel a lot more manageable to have the information organized this way.

    (And we can have a linter enforce that `type: ignore` always comes with such a comment).

  • typeguard

    Run-time type checker for Python

    Never checked? They're statically checked.

    Also, tooling like https://pydantic-docs.helpmanual.io/ can do runtime checking for important parts of your app or you can add use this https://github.com/agronholm/typeguard to enforce all types at runtime (although I haven't measured the performance impact, probably something to do in a separate environment than production?).

  • pydantic

    Data validation using Python type hints

    Never checked? They're statically checked.

    Also, tooling like https://pydantic-docs.helpmanual.io/ can do runtime checking for important parts of your app or you can add use this https://github.com/agronholm/typeguard to enforce all types at runtime (although I haven't measured the performance impact, probably something to do in a separate environment than production?).

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Ask HN: Will we see a TypeScript for Python?

    2 projects | news.ycombinator.com | 26 Feb 2023
  • Statically typed Python

    7 projects | /r/Python | 30 Nov 2021
  • JSON extra uses orjson instead of ujson

    4 projects | news.ycombinator.com | 5 Jun 2024
  • This Week In Python

    5 projects | dev.to | 10 May 2024
  • utype VS pydantic - a user suggested alternative

    2 projects | 15 Feb 2024

Did you konow that Python is
the 1st most popular programming language
based on number of metions?