flâneur — a map of the web's best reading

Python, type hints, and future annotations

blog.derlin.ch · 1,932 words · saved by 1 readers

It took me a while to find my path, but as soon as I started programming, I knew it would define me for the rest of my life. I love everything that challenges my brain and can keep it interested. I was involved in projects in numerous domains, from quantum computing for particle physics to retail store interfaces. I don't know what I enjoy the most (as long as I can crunch code), so I try everything I come up with. Currently working as a software engineer / SRE, I always have ongoing side projects and try to give back to the community through open-source and tech platforms (dev.to, StackOverflow). Aside from my work, I love reading (especially time travel fiction) and spending time with other passionate people. To make the latter even easier, I co-founded the GDG Fribourg, which I hope you will check out if you are in Switzerland. TAGS ON THIS PAGE Not long ago, I came across a bug in one of my projects that highlighted very interesting changes in how Python handles type hints at runti

Not long ago, I came across a bug in one of my projects that highlighted very interesting changes in how Python handles type hints at runtime. This made me dig into the future of type annotations, and what it means for libraries manipulating type hints at runtime. Spoiler alert: It has to do with PEP 563 . The bug A brief history of type hints Basics of type hints Introducing PEP 563, or what lies behind future annotations The explanation How to get the return type of a function after PEP 563? In Python 3.10 and newer In Python 3.9 and older A word of caution Conclusion # The bug I have a Djan

Explore this link on the map →

related reading