by rtpg · 2mo ago · 0 comments
"Oh you don't have optional dependency? Then do X" needs to happen at runtime right?
In my preference order: an explicit CLI option/envvar which requires the optional dep, a flag file on the filesystem, or an ImportError attempt if you absolutely must. Use a stub/trampoline file in the conditionals so that static analyzers and laziness analysis on that file itself still work.