Try an automatic code porting tool, like https://python-modernize.readthedocs.io/, to remove #python2 idioms. This is no silver bullet but it helps. For instance, it will detect things now in six.moves (like itertools.imap) or usage of .next() and update your code. On the other hand, it sometimes does useless things like changing "for k, v in d.iteritems():" into "for k, v in six.iteritems(d):".
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!