diff --git a/strawberry/channels/handlers/http_handler.py b/strawberry/channels/handlers/http_handler.py index 97de87de5b..369e84eb5b 100644 --- a/strawberry/channels/handlers/http_handler.py +++ b/strawberry/channels/handlers/http_handler.py @@ -300,9 +300,7 @@ def is_websocket_request( ) -> TypeGuard[ChannelsRequest]: return False - async def pick_websocket_subprotocol( - self, request: ChannelsRequest - ) -> str | None: + async def pick_websocket_subprotocol(self, request: ChannelsRequest) -> str | None: return None async def create_websocket_response( diff --git a/strawberry/codegen/query_codegen.py b/strawberry/codegen/query_codegen.py index a741cdc0c1..b3fe56b9bc 100644 --- a/strawberry/codegen/query_codegen.py +++ b/strawberry/codegen/query_codegen.py @@ -635,9 +635,7 @@ def _field_from_selection( def _unwrap_type( self, type_: type | StrawberryType - ) -> tuple[ - type | StrawberryType, Callable[[GraphQLType], GraphQLType] | None - ]: + ) -> tuple[type | StrawberryType, Callable[[GraphQLType], GraphQLType] | None]: wrapper: Callable[[GraphQLType], GraphQLType] | None = None if isinstance(type_, StrawberryOptional): diff --git a/strawberry/extensions/context.py b/strawberry/extensions/context.py index af8ffb1fe1..1baba4af29 100644 --- a/strawberry/extensions/context.py +++ b/strawberry/extensions/context.py @@ -26,7 +26,8 @@ class WrappedHook(NamedTuple): extension: SchemaExtension hook: Callable[ ..., - contextlib.AbstractAsyncContextManager[None] | contextlib.AbstractContextManager[None], + contextlib.AbstractAsyncContextManager[None] + | contextlib.AbstractContextManager[None], ] is_async: bool diff --git a/strawberry/printer/ast_from_value.py b/strawberry/printer/ast_from_value.py index 309b0f43e0..48a44af3bf 100644 --- a/strawberry/printer/ast_from_value.py +++ b/strawberry/printer/ast_from_value.py @@ -44,9 +44,7 @@ _re_integer_string = re.compile("^-?(?:0|[1-9][0-9]*)$") -def ast_from_leaf_type( - serialized: object, type_: GraphQLInputType | None -) -> ValueNode: +def ast_from_leaf_type(serialized: object, type_: GraphQLInputType | None) -> ValueNode: # Others serialize based on their corresponding Python scalar types. if isinstance(serialized, bool): return BooleanValueNode(value=serialized) diff --git a/strawberry/printer/printer.py b/strawberry/printer/printer.py index 5dc4152471..79f9e9de83 100644 --- a/strawberry/printer/printer.py +++ b/strawberry/printer/printer.py @@ -498,9 +498,7 @@ def _all_root_names_are_common_names(schema: BaseSchema) -> bool: ) -def print_schema_definition( - schema: BaseSchema, *, extras: PrintExtras -) -> str | None: +def print_schema_definition(schema: BaseSchema, *, extras: PrintExtras) -> str | None: # TODO: add support for description if _all_root_names_are_common_names(schema) and not schema.schema_directives: @@ -522,9 +520,7 @@ def print_schema_definition( return f"schema{directives} {{\n" + "\n".join(operation_types) + "\n}" -def print_directive( - directive: GraphQLDirective, *, schema: BaseSchema -) -> str | None: +def print_directive(directive: GraphQLDirective, *, schema: BaseSchema) -> str | None: strawberry_directive = directive.extensions["strawberry-definition"] if ( diff --git a/strawberry/schema/base.py b/strawberry/schema/base.py index 709ae38fa8..4ed757fae3 100644 --- a/strawberry/schema/base.py +++ b/strawberry/schema/base.py @@ -77,7 +77,13 @@ async def subscribe( @abstractmethod def get_type_by_name( self, name: str - ) -> StrawberryObjectDefinition | ScalarDefinition | EnumDefinition | StrawberryUnion | None: + ) -> ( + StrawberryObjectDefinition + | ScalarDefinition + | EnumDefinition + | StrawberryUnion + | None + ): raise NotImplementedError @abstractmethod diff --git a/strawberry/schema/types/concrete_type.py b/strawberry/schema/types/concrete_type.py index 7e4db855d7..980864b2ef 100644 --- a/strawberry/schema/types/concrete_type.py +++ b/strawberry/schema/types/concrete_type.py @@ -16,7 +16,9 @@ @dataclasses.dataclass class ConcreteType: - definition: StrawberryObjectDefinition | EnumDefinition | ScalarDefinition | StrawberryUnion + definition: ( + StrawberryObjectDefinition | EnumDefinition | ScalarDefinition | StrawberryUnion + ) implementation: GraphQLType diff --git a/strawberry/types/field.py b/strawberry/types/field.py index 9d65a0f5f7..79ee8241e6 100644 --- a/strawberry/types/field.py +++ b/strawberry/types/field.py @@ -370,7 +370,9 @@ def copy_with( ) -> Self: new_field = copy.copy(self) - override_type: StrawberryType | type[WithStrawberryObjectDefinition] | None = None + override_type: StrawberryType | type[WithStrawberryObjectDefinition] | None = ( + None + ) type_ = self.resolve_type() if has_object_definition(type_): type_definition = type_.__strawberry_definition__ diff --git a/tests/experimental/pydantic/schema/test_federation.py b/tests/experimental/pydantic/schema/test_federation.py index 0ac89a1c9c..6bb949bf66 100644 --- a/tests/experimental/pydantic/schema/test_federation.py +++ b/tests/experimental/pydantic/schema/test_federation.py @@ -1,4 +1,3 @@ - from pydantic import BaseModel import strawberry diff --git a/tests/http/clients/channels.py b/tests/http/clients/channels.py index e1deb2d0cd..c2aa8b9f12 100644 --- a/tests/http/clients/channels.py +++ b/tests/http/clients/channels.py @@ -35,9 +35,7 @@ ) -def generate_get_path( - path, query: str, variables: dict[str, Any] | None = None -) -> str: +def generate_get_path(path, query: str, variables: dict[str, Any] | None = None) -> str: body: dict[str, Any] = {"query": query} if variables is not None: body["variables"] = json_module.dumps(variables) @@ -271,9 +269,7 @@ def __init__( class ChannelsWebSocketClient(WebSocketClient): - def __init__( - self, client: WebsocketCommunicator, accepted_subprotocol: str | None - ): + def __init__(self, client: WebsocketCommunicator, accepted_subprotocol: str | None): self.ws = client self._closed: bool = False self._close_code: int | None = None diff --git a/tests/schema/test_subscription.py b/tests/schema/test_subscription.py index 8a0d043527..ba43e9e0ca 100644 --- a/tests/schema/test_subscription.py +++ b/tests/schema/test_subscription.py @@ -187,9 +187,7 @@ class Subscription: @strawberry.subscription async def example_with_annotated_union( self, - ) -> AsyncGenerator[ - Annotated[C | D, strawberry.union("UnionName")], None - ]: + ) -> AsyncGenerator[Annotated[C | D, strawberry.union("UnionName")], None]: yield C(c="Hi") schema = strawberry.Schema(query=Query, subscription=Subscription) diff --git a/tests/websockets/test_graphql_transport_ws.py b/tests/websockets/test_graphql_transport_ws.py index 6c8019f777..b543b34206 100644 --- a/tests/websockets/test_graphql_transport_ws.py +++ b/tests/websockets/test_graphql_transport_ws.py @@ -975,7 +975,9 @@ async def test_subsciption_cancel_finalization_delay(ws: WebSocketClient): ) while True: - next_or_complete_message: NextMessage | CompleteMessage = await ws.receive_json() + next_or_complete_message: ( + NextMessage | CompleteMessage + ) = await ws.receive_json() assert next_or_complete_message["type"] in ("next", "complete") diff --git a/tests/websockets/test_graphql_ws.py b/tests/websockets/test_graphql_ws.py index 84f05477b9..f8fddccb03 100644 --- a/tests/websockets/test_graphql_ws.py +++ b/tests/websockets/test_graphql_ws.py @@ -262,7 +262,9 @@ async def test_sends_keep_alive(aiohttp_app_client: HttpClient): # get but they should be more than one. keepalive_count = 0 while True: - ka_or_data_message: ConnectionKeepAliveMessage | DataMessage = await ws.receive_json() + ka_or_data_message: ( + ConnectionKeepAliveMessage | DataMessage + ) = await ws.receive_json() if ka_or_data_message["type"] == "ka": keepalive_count += 1 else: