Hacker News new | ask | show | jobs
by maleldil 639 days ago
(Strict) Typed Python isn't that bad either, and LLMs seem to be quite good at generating that, given how popular Python is.

Unfortunately, it tends to generate outdated types (e.g. `List` instead of `list`, `Optional[T]` instead of `T | None`, import `Iterable` from `typing` instead of `collections.abc`), so you always need to tell it to use the right one.

2 comments

Should be possible to fix automatically though? Something like https://github.com/PyCQA/modernize, but for type hints.

Edit: there is pyupgrade which can do this: https://github.com/asottile/pyupgrade#pep-585-typing-rewrite...

I still use Optional[T] so definitely not just the LLM :)