[1.7.x] Fixed some flake8 errors.

Backport of 9d30412a5a from master