You could use:
fissix package and to get full understanding, read the docs here https://pypi.org/project/fissix/
futurize package that plays the same role or fissix, check the repo https://python-future.org/futurize.html
also you might glance this repo https://github.com/PyCQA/modernize.