Set scene/file as dirty through python

I have a simple addon that alow me to precisely tilt points of a curve through properties.
However using them won’t mark the scene as dirty and the user won’t be prompted with the “save before close” popup.

Clicking a button just to mark the scene as dirty isn’t the best user experience

I tried multiple ways to circumvent that. Calling operators, adding/moving objects, changing scene propertys, timers to keep track of the changes, etc. Apparently nothing done through python can set the scene as dirty.

Am I missing something? Thanks.

A timer seems to work:

import bpy

def delayed_check():
    print(f"in a timer callback: {bpy.data.is_dirty}")
    
print(f"before object creation: {bpy.data.is_dirty}")
o = bpy.data.objects.new("temp", None)
print(f"after object creation: {bpy.data.is_dirty}")

bpy.app.timers.register(delayed_check)

before object creation: False
after object creation: False
in a timer callback: True