This script works till 3.6, but not 4.0.
import bpy
for a in bpy.context.screen.areas:
if a.type == 'DOPESHEET_EDITOR':
#deselect the keyframes
bpy.ops.action.select_all({"area" : a}, action="DESELECT")
break
4.0 says "ValueError: 1-2 args execution context is supported" in bpy.ops.action.select_all