flake8 fixes (unused imports and variables).
Fixed #21790 -- Removed reliance on an assert in auth.get_user().

Thanks matklad for the report.