4 ms·
You can also use from __future__ import annotations so the quotes become unnecessary. https://peps.python.org/pep-0563/ https://peps.python.org/pep-0563/
by npage97 3y ago
You can also use from __future__ import annotations so the quotes become unnecessary. https://peps.python.org/pep-0563/ https://peps.python.org/pep-0563/
- insanitybit 3y agoDoes that work with recursive types? I have had mixed results with `from __future__ import annotations` personally, but I haven't written much Python in ~a year or so.
- deleted 3y ago[deleted]
- FreakLegion 3y agoIt's worked for many years, but you won't often see it used outside of class definitions because all of the other tools struggle with it (Pylint, Flake8, Pylance, etc. spit out some variation of an undefined variable error).
- insanitybit 3y agoI don't think it has worked for years. I had used that same exact __annotations__ and my recollection was that recursive types still did not work.
- FreakLegion 3y agoIt's worked for years. I've been using it the whole time.