Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Didn't Python 3.5 introduce optional typings?


Only annotations which can be checked by mypy or other linters. I think cpython doesn't check them at runtime.


And mypy is still very immature. You can’t denote a recursive type (e.g., a JSON type) or specify a callback that takes keyword arguments. Even getting it to load type annotations from third party packages is hard in many cases. Worse, it seems to be improving at a snail’s pace if at all.


A "JSON" type in Python is just an untyped dictionary. Is that not what you're looking for?

Also, python's type-hinting supports forward-references which are what you would use for recursive or "self-referencing" types.

Personally, I like the slow pace they're taking with the typing. It's touching the core usage of the language in a fundamental way and I don't think that can be rushed. We're seeing lots of community growth around the type-hinting, even using them at run-time, which is amazing to watch and marvel at.


Untyped dictionaries are a superset of JSON. JSON is (more or less) precisely:

   Dict[str, JSON] | List[JSON] | str | float | int | bool | None


Python indeed doesn't check them. Really they're just syntactic sugar for what you'd otherwise put in documentation.


Yes but hardly any code uses them yet. Hell there's still lots of code on Python 2 (yes really, no I'm not imagining it).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: