Roman Imankulov

Roman Imankulov

Full-stack Python web developer from Porto

search results (esc to close)
25 Aug 2020

5 reasons to love Python type hints

I’m a big fan of type hints, and I honestly don’t understand why some people find it ugly or unpythonic.

  1. They improve the auto-complete and code navigation in the IDE.
  2. They protect you against trivial errors and remind you about corner cases.
  3. Beyond IDEs, more and more tools in the Python ecosystem take advantage of typing information. The FastAPI framework is the first example that comes to my mind.
  4. They are like documentation, that is testable, both human- and machine-readable, and never outdated.
  5. They make you think about your code and highlight code smell. Do you need to return Optional, or it’s better to implement a null object pattern? Do you need to return a Union or split your function in two?

Overall, they make explicit many implicit assumptions and connections in your code. Maybe people who complain that type hints are ugly fail to admit that type hints just uncover deficiencies of their own system?

Roman Imankulov

Hey, I am Roman, and you can hire me.

I am a full-stack Python web developer who loves helping startups and small teams turn their ideas into products.

More about me and my skills