aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-11-02 15:38:49 +0300
committerFrederick Muriuki Muriithi2023-11-02 15:38:49 +0300
commitc5d4a6f8104af1eaa0c9dfd8ea7025a673de731e (patch)
tree6b6b8c4ee01e62758867b66d19ef6b383e94c78b /gn_auth
parent3f5b7ef490b82ab79e3f72ebc5546c9a4118a920 (diff)
downloadgn-auth-c5d4a6f8104af1eaa0c9dfd8ea7025a673de731e.tar.gz
mypy: Fix typing errors.
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/auth/authorisation/resources/models.py6
-rw-r--r--gn_auth/commands.py4
2 files changed, 6 insertions, 4 deletions
diff --git a/gn_auth/auth/authorisation/resources/models.py b/gn_auth/auth/authorisation/resources/models.py
index a9d1378..15bb72f 100644
--- a/gn_auth/auth/authorisation/resources/models.py
+++ b/gn_auth/auth/authorisation/resources/models.py
@@ -298,7 +298,7 @@ def attach_resources_data(
with db.cursor(conn) as cursor:
return tuple(
resource for categories in
- (resource_data_function[category.resource_category_key](
+ (resource_data_function[category.resource_category_key](# type: ignore[operator]
cursor, rscs)
for category, rscs in organised.items())
for resource in categories)
@@ -377,7 +377,7 @@ def save_resource(
def user_roles_on_resources(conn: db.DbConnection,
user: User,
- resource_ids: tuple[UUID] = tuple()) -> dict:
+ resource_ids: tuple[UUID, ...] = tuple()) -> dict:
"""Get roles on resources for a particular user."""
def __setup_roles__(old_roles, row):
roles = {role.role_id: role for role in old_roles}
@@ -409,7 +409,7 @@ def user_roles_on_resources(conn: db.DbConnection,
"INNER JOIN role_privileges AS rp ON r.role_id=rp.role_id "
"INNER JOIN privileges AS p ON rp.privilege_id=p.privilege_id "
"WHERE ur.user_id=?")
- params = (str(user.user_id),)
+ params: tuple[str, ...] = (str(user.user_id),)
if len(resource_ids) > 0:
pholders = ", ".join(["?"] * len(resource_ids))
diff --git a/gn_auth/commands.py b/gn_auth/commands.py
index cc00413..02bed10 100644
--- a/gn_auth/commands.py
+++ b/gn_auth/commands.py
@@ -44,7 +44,9 @@ Returns the name of the specific redis hash for the specific task.
conn.hset(name=unique_id, key="env", value=json.dumps(env))
return unique_id
-def run_cmd(cmd: str, success_codes: Tuple = (0,), env: str = None) -> Dict:
+def run_cmd(cmd: str,
+ success_codes: Tuple = (0,),
+ env: Optional[str] = None) -> Dict:
"""Run CMD and return the CMD's status code and output as a dict"""
parsed_cmd = json.loads(cmd)
parsed_env = (json.loads(env) if env is not None else None)