9
When to use typing.TYPE_CHECKING
(feddit.de)
Welcome to the Python community on the programming.dev Lemmy instance!
October 2023
November 2023
Past
July 2023
August 2023
September 2023
You still need to import the type before using it in a stringified type annotation for it to be valid though, so you'd need the import in an
if TYPE_CHECKING:
block either way, no?Yes, but if it’s in a TYPE_CHECKING block I can ONLY use the annotation with quotes*, which is why I only use that method if I must.
from __future__ import annotations
as I’ve just learned.Ah yeah, I see what you meant.