In Blender versions before 4.0, I would execute text blocks with the following Python code.
# Retrieve the text file
rig_file = bpy.data.texts["hello.py"]
rig_text = rig_file.as_string()
Modify text string as needed here ...
Execute the script
ctx = bpy.context.copy()
ctx['edit_text'] = rig_file
bpy.ops.text.run_script(ctx)
This worked flawlessly in 3.6. Now in 4.0, passing in context overrides has been depricated in favor of Context.temp_override.
How would I execute this code in 4.0 and beyond? I know it would have to be in the syntax of the temp_override, but what do I pass in to the with block to make this work?
# [4.0] Execute the script
ctx = bpy.context.copy()
ctx['edit_text'] = rig_file
with bpy.context.temp_override(): # What do I pass in?
bpy.ops.text.run_script() # Is this still correct in 4.0?
Edit: For convenience I'll post the documentation on text operators: https://docs.blender.org/api/current/bpy.ops.text.html
You will notice that run_script() doesn't take in anything anymore, and that it is described as running the 'active script'. The question is, how do I set my text file as the active script to run?