A more direct refactor of the original code for 5.0+ would be this:
import bpy
from bpy_extras import anim_utils
anim_data = bpy.data.objects["Armature"].animation_data
channelbag = anim_utils.action_get_channelbag_for_slot(anim_data.action, anim_data.action_slot)
for fcurve in channelbag.fcurves:
if "Bone" in fcurve.data_path:
fcurve.extrapolation = "LINEAR"
In the 5.0 release notes there is a section detailing how code dealing with fcurves should be translated: https://developer.blender.org/docs/release_notes/5.0/python_api/
If you want to know more about slotted actions, and the reasons this was changed, a good start might be the 4.4 relase notes where this was introduced: https://developer.blender.org/docs/release_notes/4.4/animation_rigging/
The python API changes for that version are also worth reading: https://developer.blender.org/docs/release_notes/4.4/python_api/
Hope that helps!