Verify with cat -v foo.py
that no TABs have crept into your sources where you believed there would be only SPACEs.
You run flake8 from within vim, but during testing also run it from the command line:
$ flake8 foo.py
Ensure that there is no .pylintrc or flake8.rc config file when you do that, so it is running with default config. Also, verify there is no two-space indenting of code within foo.py which flake8 could sense and use as default.