Live data from Hacker News

Python developers are embracing type hints

pyrefly.org

1–10 of 581 posts

Re: Python developers are embracing type hints

#2
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).

Re: Python developers are embracing type hints

#4

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++.

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).

Re: Python developers are embracing type hints

#7
post #4

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++.

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).

Absolutely the general accepted wisdom in line with best practices - that are often ignored

Re: Python developers are embracing type hints

#8
post #6

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.

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.

Re: Python developers are embracing type hints

#9
post #5

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.

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.

Re: Python developers are embracing type hints

#10
Typescript turned me into a believer but my gosh do python typings feel clumsy and quickly busy up files. I get why, and it’s not exactly realistic, but I wish a lot of it didn’t require an import.

Whatever the solution is, it doesn’t include giving up on Python typings.

Post reply on HN