This is a minor nit, but why is OP's script a Python script with a .sh extension? I know the extension doesn't "matter", but if I see a .sh extension I'm expecting a Bash script.
Cause it was written by AI?
Cause it was written by AI?