Fix flake8 errors.
Use ternary.