Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 25, 2024
1 parent c79acee commit 1f2ad37
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 31 deletions.
4 changes: 1 addition & 3 deletions strawberry/channels/handlers/http_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 1 addition & 3 deletions strawberry/codegen/query_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion strawberry/extensions/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions strawberry/printer/ast_from_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 2 additions & 6 deletions strawberry/printer/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 (
Expand Down
8 changes: 7 additions & 1 deletion strawberry/schema/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion strawberry/schema/types/concrete_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

@dataclasses.dataclass
class ConcreteType:
definition: StrawberryObjectDefinition | EnumDefinition | ScalarDefinition | StrawberryUnion
definition: (
StrawberryObjectDefinition | EnumDefinition | ScalarDefinition | StrawberryUnion
)
implementation: GraphQLType


Expand Down
4 changes: 3 additions & 1 deletion strawberry/types/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
1 change: 0 additions & 1 deletion tests/experimental/pydantic/schema/test_federation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

from pydantic import BaseModel

import strawberry
Expand Down
8 changes: 2 additions & 6 deletions tests/http/clients/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions tests/schema/test_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion tests/websockets/test_graphql_transport_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
4 changes: 3 additions & 1 deletion tests/websockets/test_graphql_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1f2ad37

Please sign in to comment.