I migrated this to Python 3. @Cassady @pankajsz give it a try and let me know if you see anything out of place.
I have a question for @vitor: when a python script is an executable, it doesn't make sense to add the export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH command to the script filter, correct?
In that case, considering that the shebang in the executable is #!/usr/bin/python3, it will not work on brew-installed pythons? Is there a way to make it compatible, in other words an equivalent of export PATH=/opt/homebrew/bin:/usr/local/bin:$PATH for executables?