This is precisely what motivated me to create https://github.com/zhurong2020/pyobfus.
It is a Python AST-based code obfuscator. The Community Edition is licensed under Apache -2.0 and supports framework presets for FastAPI, Django, Flask, Pydantic, Click, and SQLAlchemy, as well as a stable JSON CLI and MCP server.
Pyobfus does not compromise obfuscation; instead, it keeps “readability” on the developer’s local machine. During the build, use `--save-mapping mapping.json`, which saves the mapping between the original identifiers and the obfuscated names; in production, only the obfuscated code runs, and external observers still see names like I0 and I1. When error logs come back from production, developers can use `--unmap` and this `mapping.json` file to restore the traceback locally: `pyobfus --unmap --trace error.log --mapping mapping.json`. The resulting stack trace will display the original class and function names, which developers can understand, and AI coding tools like Claude Code and Cursor can also make sense of it with the source code semantics. The key point is that `mapping.json` is not distributed with the code; it is kept only by the developer. Production builds remain obfuscated, while the debugging entry point remains on the local machine.