(One of my summaries of the PyUtrecht meetup in Utrecht, NL).
Note: Victorien is currently the number one person maintaining Pydantic. Pydantic is basically “dataclasses with validation”.
There was a show of hands: about 70% uses type hints. Type hints has been around since
python 3.5. There have been improvements during the years like str|None instead of
Union(str, None) in 3.10, for instance.
Something I didn’t know: you can always introspect type hints when running your python
code: typing.get_type_hints(my_func).
Getting typing-related changes into Python takes a lot of work. You need to implemeent the changes in CPython. You have to update the spec. And get it supported by the major type checkers. That’s really a difference to typescript, as typing is built-in from the start, there.
Something that helps typing in the future is 3.15’s lazy from xxx import yyy import.
There’s an upcoming PEP 764, “inline typed dictionaries”:
def get_movie() -> {"name": str, "year": int}:
# At least something like this ^^^, I can't type that quickly :-)
...
He has some suggestions for a new syntax, using something like <{ .... }>, but
getting a syntax change into Python takes a lot of talking and a really solid proposal.
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):