[1.7.x] flake8 fixes.

Backport of 45c2d1f5d9 from master.