Making Any a builtin object, referring to typing.Any

It’s interesting to me to reflect on this thread. The last few years I’ve had a much more complete experience of teaching other people about the type system, learning more about it myself, and working with a team with more varied technical backgrounds.

I now have a much stronger feeling that Any is often reached for too quickly and too easily, especially when someone’s abstractions are all mixed up and they can’t describe (with or without the type system!) what they’re doing.
I still use Any a lot, but I’m more convinced that its usage needs no improvement.

I’m also a strong proponent of import typing as t style, and I’ve even convinced skeptical team members after trying flake8-typing-as-t on some repos.
This style puts the full vocabulary of typing in easy reach, making it more of a natural extension of the language.

For anyone who likes the idea of moving things from typing to builtins, try working for a while with import typing as t as your normative style[1], and see if you end up having your mind changed.


  1. And if you use flake8-typing-as-t, let me know how you like it, or file bugs if it doesn’t work for you! ↩︎

6 Likes