From cc4b41165766a1f1a0b8981887ff127a65f3605e Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 15 Jul 2024 16:59:15 +0400 Subject: [PATCH] refactor: Replace strawberry.types.Info with just Info --- selfprivacy_api/graphql/schema.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/selfprivacy_api/graphql/schema.py b/selfprivacy_api/graphql/schema.py index 534bacf..b49a629 100644 --- a/selfprivacy_api/graphql/schema.py +++ b/selfprivacy_api/graphql/schema.py @@ -4,6 +4,7 @@ import asyncio from typing import AsyncGenerator, List import strawberry +from strawberry.types import Info from selfprivacy_api.graphql import IsAuthenticated from selfprivacy_api.graphql.mutations.deprecated_mutations import ( @@ -144,11 +145,11 @@ class Mutation( # A cruft for Websockets -def authenticated(info: strawberry.types.Info) -> bool: +def authenticated(info: Info) -> bool: return IsAuthenticated().has_permission(source=None, info=info) -def reject_if_unauthenticated(info: strawberry.types.Info): +def reject_if_unauthenticated(info: Info): if not authenticated(info): raise Exception(IsAuthenticated().message) @@ -161,24 +162,20 @@ class Subscription: demands it while the spec is vague in this area.""" @strawberry.subscription - async def job_updates( - self, info: strawberry.types.Info - ) -> AsyncGenerator[List[ApiJob], None]: + async def job_updates(self, info: Info) -> AsyncGenerator[List[ApiJob], None]: reject_if_unauthenticated(info) return job_update_generator() @strawberry.subscription # Used for testing, consider deletion to shrink attack surface - async def count(self, info: strawberry.types.Info) -> AsyncGenerator[int, None]: + async def count(self, info: Info) -> AsyncGenerator[int, None]: reject_if_unauthenticated(info) for i in range(10): yield i await asyncio.sleep(0.5) @strawberry.subscription - async def log_entries( - self, info: strawberry.types.Info - ) -> AsyncGenerator[LogEntry, None]: + async def log_entries(self, info: Info) -> AsyncGenerator[LogEntry, None]: reject_if_unauthenticated(info) return log_stream()