[1.7.x] Fixed flake8 errors.

Backport of 4b25ebf112 from master