I didn’t even remember I shared this script in the past
But the version I currently use is at https://github.com/phw/picard-plugins/blob/formathelpers/plugins/formathelpers/init.py and that takes care of the bug.
Keep in mind that these functions are a bit unreliable in any case. It mainly just detects the lossless status based on file extension with some special handling for m4a files which is more a heuristic than a reliable detection of lossless codec. This works for my use case, but is also the reason why I never submitted this plugin for inclusion in the official plugin list. Basically I don’t want to support this code beyond what it is already doing and which fits my needs.