True, but I think that source transformation on import are already supported in Python ("officially") based on importlib [0-1].
Here's an example use cases where the author is trying to create a Python enum from Thrift specs: [2]. The issue here is that the spec code is not necessarily valid Python, but can be fixed easily with some search & replace operations.
One of the benefits of implementing your own module finder and loader is that you could use a separate file extension to avoid confusion with actual Python code.
This seems like an interesting avenue for static analysis tools, code generators, (etc.) to explore. Is it a viable approach?
I'd be interested in some analysis on this as a mechanism: performance, maintability, etc. wise.
The "dont do this" argument writes itself; nevertheless, its worth exploring.