Disclaimer: There seem to be differences here both between ArcMap and ArcPro, as well as Python 2 and Python 3. That said, the issue seems to be on ArcPro's end.
--------------------------------------------------
Simplified Precis:
I have a geoprocessing tool that runs on a script we'll call Toolscript.py. This is part of a suite of tools I build & maintain for our team, and they reference a core library that we'll call Assets.py. Toolscript.py imports Assets.py, and python automatically creates Assets.pyc at runtime. In the old Desktop days with Python 2, this would be saved in the same place as the Assets.py, whereas Python 3 now puts the compiled file in a __pycache__ subdirectory.
If I make edits to Assets.py, I generally delete Assets.pyc, and have Python generate a fresh one. Especially if I'm actively writing & testing a script, I will end up doing this frequently, to make sure that my tool that I'm testing is actually using the correct version of the library file.
The Problem:
In ArcGIS Desktop 10.7, deleting Assets.pyc was all I had to do, and I could easily test & iterate on the fly. My tools always imported the most current version of the library, without restarting ArcGIS.
In ArcGIS Pro 3.1, there seems to be a cached file stored inside ArcGIS Pro. Even when I delete Assets.pyc, my tools seem to try to reference the old file. In addition to not getting expected results from whatever fix I just coded, my tracebacks start pointing to nonsense like blank lines (assumedly because the Assets.py and Assets.pyc being referenced by ArcGIS Pro no longer match.
This means any time I make even a minor change to Assets.py, I have to delete Assets.pyc AND close ArcGIS Pro. This is hugely inefficient when I'm in active R&D and needing to fix things in Assets.py.
Is there a setting I've missed somewhere or some misunderstanding of how ArcGIS Pro handles imported python scripts, now? I've dug up a few old posts on similar issues, but they mostly seem to have been muddied with other issues and/or not actually solved. I've also seen reference to importing the reload module from importlib, but I can't help but wonder why I suddenly need this in Pro when I didn't back in Desktop? I'm not seeing this come up outside of ArcGIS in other Python discussions, though admittedly that searching has been limited.