Also, the last line to check for 'one-liners' won't get them all:
$ grep -r "if __name__ == '__main__'" /path/to/lib
Should be: $ grep -r "if __name__ == ['\"]__main__['\"]" /path/to/lib