Functions that declare functions in default arguments always execute the function at the first run time.
This is confusing and results in extra code.
Maybe I’m too lazy.
I made a small botnet with different consoles and processes that are accessed through a private local network for my work. Each worker has its own dynamic console based on the custom thread name. I noticed that the printouts were always thread 0 at the beginning.
I am aware that it may be poorly stated, but perhaps it is good to consider whether it is valid to allow the execution of functions as default arguments.
As is mentioned by @sirosen in this post, pylint and flake8-bugbear provides the tool to check for these conditions and provide you a warning in your code editor (I haven’t tried them yet, but it should draw a wavy yellow line in VSCode when the conditions you configured are met).
This is not exactly the same as you requested (disallow), but should work for your use case.