[1.7.x] Fixed flake8 warnings.

Backport of 392e11945fa246d751d23bb515703fcaf55dfa26 from master