It’s a POSIX thing, and it has nothing to do with the file extension. The OP is right: file extensions are optional (and, as shown here, often actively misleading), but if they’re present they should match the actual file type. Which, in this case, is Python code , not a shell script.
[ my public key: https://keybase.io/klmr; my proof: https://keybase.io/klmr/sigs/F9zackvFn6PE00C5T_IlAkRQPH_CVvp0aqSA-hysJ30 ]