Fixes #6236 Also included in this commit are the changes need to make flake8 pass for the existing python file