This PR improves the flake8 linter configuration, and then fixes new warnings that were flagged as a result.