Something like this does the trick:
if TYPE_CHECKING: import WhateverClass
https://docs.python.org/3/library/typing.html#typing.TYPE_CH...
if TYPE_CHECKING: import WhateverClass
https://docs.python.org/3/library/typing.html#typing.TYPE_CH...
(And some types are defined in the typeshed so only exist to be imported during type checking; eg the type checker lib itself is a dependency in this case)
if False:
import blah
unironically as good design and more than a necessary evil until a long-term solution emerges then we’ve jumped the shark.