Some static analysis tools (particularly IDEs) used to process code under an if False
, which was pretty useful. You could have generated code to directly link to the source files without impacting runtime (e.g. the most simplistic sys.path.append("STRING\\LITERAL")
possible). Then the tools could coalesce around supporting this.
However, they’ve gotten too smart right now, so at a minimum you need to import typing
so you can use the boolean in there to avoid the runtime impact. And you’d still need to design some kind of meta system for them to replace the file with another.
For now, I’d just include enough information in the __init__
file in a predictable enough way that if they choose they can find the original file, then leave it up to the tools (and their users).