For one of my projects, I've written a wrapper script that compiles UI files into importable modules and also generate type hinting stubs for UI files. By default, it creates .pyi type hinting stubs for UI files found recursively under a given source directory, and puts them in the same hierarchy under a given target directory. I use it to have auto-completion for UI files without having the compiled code in the source tree.
The Python module paths are hard-coded for the project at the top of the script, so you should adapt them.
Source code is here: https://chiselapp.com/user/luziferius/repository/MTGProxyPrinter/file?name=scripts/compile_ui_files.py&ci=port_pyside6
Also note that using the --purge existing flag assumes the target path can be deleted and re-created without interfering, so you may need to adapt it, if you intersperse automatically generated code with manually written code. (If the --purge-existing flag is given, it performs shutil.rmtree on the target path!)