Use autopep8 utility to resolve issues like spaces before brackets and wrong hanging indentation. Also treat objects like boolean variables to check whether they are None or not.
Remove unused imports and fix import sorting using isort utility.