From 1db33918263558f134b3017ea51315f7e0469ccb Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 18 Dec 2021 03:04:37 +0100 Subject: [PATCH] fix(roles): Minor documentation + typings --- flaschengeist/controller/roleController.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/flaschengeist/controller/roleController.py b/flaschengeist/controller/roleController.py index 204adad..86f74ab 100644 --- a/flaschengeist/controller/roleController.py +++ b/flaschengeist/controller/roleController.py @@ -1,9 +1,10 @@ +from typing import Union from sqlalchemy.exc import IntegrityError from werkzeug.exceptions import BadRequest, Conflict, NotFound +from flaschengeist import logger from flaschengeist.models.user import Role, Permission from flaschengeist.database import db, case_sensitive -from flaschengeist import logger from flaschengeist.utils.hook import Hook @@ -11,7 +12,15 @@ def get_all(): return Role.query.all() -def get(role_name) -> Role: +def get(role_name: Union[int,str]) -> Role: + """Get role by ID or name + Args: + role_name: Name or ID of the role + Returns: + Matching role + Raises: + NotFound + """ if type(role_name) is int: role = Role.query.get(role_name) else: