Block a user
bpy.ops.wm.open_mainfile command overwrite the existing file without warning
bpy.ops.wm.open_mainfile command overwrite the existing file without warning
So the final working solution should be,
bpy.ops.wm.open_mainfile('INVOKE_DEFAULT', filepath=r"file.blend", display_file_selector=False)
Thanks @iss & @lichtwerk
bpy.ops.wm.open_mainfile command overwrite the existing file without warning
Yes 'INVOKE_DEFAULT' context shows a "save file" warning, but it also opens up "Blender file view" to open a file instead of opening a file mentioned in filepath argument.
bpy.ops.wm.open_mainfile command overwrite the existing file without warning
Yes, it is working differently on Mac.
Blender - 3.2.2 Mac - M1 Pro
bpy.ops.wm.open_mainfile command overwrite the existing file without warning
bpy.ops.wm.open_mainfile command overwrite the existing file without warning