Keymap sets a toggle.
The operator has two properties,
Sets the object interaction mode
Mesh object active
The TAB Shortcut The
toggle property is set to
which correlates to
GPencil object active
Why is it blank when GP is active, the keymap uses 'EDIT' as the setting, which is not available as an enum item. (See below) Appears to be some dodgy fix in place behind the scenes, replacing 'EDIT' with a startswith 'EDIT' option.
The shortcut can be emulated by emulating this.
ob = bpy.context.object
mode = 'EDIT_GPENCIL' if ob.type == 'GPENCIL' else 'EDIT',
use this in your scripts to emulate tab.
On the "Non Matching". An enum property can be dynamic, ie items added / removed based on context. If a grease pencil object is active the options are different for if a mesh object is active, etc.
The documentation shows all possible items, of which only a subset will be valid, based on context.
On further investigation, the shortcut is using
this can be confirmed by pressing TAB with GP object active and in python console
<bpy_struct, Operator("GPENCIL_OT_editmode_toggle") at 0x7f3221be1988>
when the context object is a gpencil, so without any knowledge of context, could use a try catch clause
mode = 'EDIT',
which will still throw a runtime error if the context object is None for example.