mypy changes

This commit is contained in:
mike cullerton 2022-06-30 08:06:47 -04:00
parent eca82ae275
commit 66fc71a729
1 changed files with 6 additions and 3 deletions

View File

@ -175,11 +175,14 @@ class UserService:
)
@staticmethod
def get_principal_by_user_id(user_id: int) -> Union[PrincipalModel, None]:
def get_principal_by_user_id(user_id: int) -> PrincipalModel:
"""Get_principal_by_user_id."""
principal: Union[PrincipalModel, None] = (
principal: PrincipalModel = (
db.session.query(PrincipalModel)
.filter(PrincipalModel.user_id == user_id)
.first()
)
return principal
if principal:
return principal
raise ApiError(code='no_principal_found',
message=f"No principal was found for user_id: {user_id}")