[1.7.x] Fixed flake8 errors.

Backport of fddd95254e from master