[HN Gopher] Why Today's Python Developers Are Embracing Type Hints
___________________________________________________________________
Why Today's Python Developers Are Embracing Type Hints
Author : ocamoss
Score : 13 points
Date : 2025-09-24 11:23 UTC (3 days ago)
(HTM) web link (pyrefly.org)
(TXT) w3m dump (pyrefly.org)
| LoganDark wrote:
| I think I've always used Python type hints, but that was
| partially because early versions of Discord.py relied on them
| (maybe it still does). But it was also because I like to be able
| to mentally verify my code's correctness before running it, and
| waiting for runtime errors is comparatively a huge waste of time
| (in my opinion).
| secondcoming wrote:
| I recently had to debug someone else's Python code and trying to
| figure out what variables are was a massive headache, especially
| coming from C++.
| skydhash wrote:
| I do not program that much in python, but I believe the general
| accepted wisdom in dynamic languages was explicit name and load
| of documentations (as comments and docstrings).
| imron wrote:
| Absolutely the general accepted wisdom in line with best
| practices - that are often ignored
| lacker wrote:
| Type hints are much easier to use nowadays than they were a few
| years ago, because the agentic tools like Claude Code are very
| good at converting an existing codebase to using type hints.
| OutOfHere wrote:
| The flip side of it is that Claude Code will have a very bad
| time in a code base with grossly unsatisfiable or conflicting
| types (where a type checker would fail the project). A human
| should always first ensure that the types are broadly correct,
| with or without the assistance of code tools.
| imron wrote:
| I enforce strong types on all Python code I'm responsible for -
| and make sure others don't play fast and loose with dict[str,
| Any] when they could use a well defined type.
|
| Doing otherwise is just asking for prod incidents.
| scuff3d wrote:
| I worked on a project that did this. Drove me absolutely nuts.
| It's like having all the worst parts of a dynamic language and
| a static language with none of the benefits.
|
| I'd much rather just work in a statically typed language from
| the start.
___________________________________________________________________
(page generated 2025-09-27 23:00 UTC)