4 ms·
There’s a good pattern for this using “if typing.TYPE_CHECKING:”... by either only importing them while type checking or by checking “if not typing.TYPE_CHECKIN
by techdragon 6y ago
There’s a good pattern for this using “if typing.TYPE_CHECKING:”... by either only importing them while type checking or by checking “if not typing.TYPE_CHECKING:” you could set an object type like Any, or your own custom one, as the value of all your imported types which should avoid most runtime errors I can think of.