Skip to content

Commit f852c38

Browse files
committed
Applied formatting
1 parent 5e7b2da commit f852c38

File tree

9 files changed

+44
-26
lines changed

9 files changed

+44
-26
lines changed

src/graphql_server/asgi/__init__.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@
4545
)
4646

4747
if TYPE_CHECKING:
48-
from collections.abc import AsyncGenerator, AsyncIterator, Mapping, Sequence # pragma: no cover
48+
from collections.abc import ( # pragma: no cover
49+
AsyncGenerator,
50+
AsyncIterator,
51+
Mapping,
52+
Sequence,
53+
)
4954

5055
from graphql.type import GraphQLSchema # pragma: no cover
5156
from starlette.types import Receive, Scope, Send # pragma: no cover
@@ -112,7 +117,9 @@ async def iter_json(
112117
async def send_json(self, message: Mapping[str, object]) -> None:
113118
try:
114119
await self.ws.send_text(self.view.encode_json(message))
115-
except WebSocketDisconnect as exc: # pragma: no cover - network errors mocked elsewhere
120+
except (
121+
WebSocketDisconnect
122+
) as exc: # pragma: no cover - network errors mocked elsewhere
116123
raise WebSocketDisconnected from exc
117124

118125
async def close(self, code: int, reason: str) -> None:

src/graphql_server/channels/testing.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ def __init__(
7171
subprotocols: an ordered list of preferred subprotocols to be sent to the server.
7272
**kwargs: additional arguments to be passed to the `WebsocketCommunicator` constructor.
7373
"""
74-
if connection_params is None: # pragma: no cover - tested via custom initialisation
74+
if (
75+
connection_params is None
76+
): # pragma: no cover - tested via custom initialisation
7577
connection_params = {}
7678
self.protocol = protocol
7779
subprotocols = kwargs.get("subprotocols", [])
@@ -139,7 +141,9 @@ async def subscribe(
139141
},
140142
}
141143

142-
if variables is not None: # pragma: no cover - exercised in higher-level tests
144+
if (
145+
variables is not None
146+
): # pragma: no cover - exercised in higher-level tests
143147
start_message["payload"]["variables"] = variables
144148

145149
await self.send_json_to(start_message)
@@ -155,7 +159,9 @@ async def subscribe(
155159
ret.errors = self.process_errors(payload.get("errors") or [])
156160
ret.extensions = payload.get("extensions", None)
157161
yield ret
158-
elif message["type"] == "error": # pragma: no cover - network failures untested
162+
elif (
163+
message["type"] == "error"
164+
): # pragma: no cover - network failures untested
159165
error_payload = message["payload"]
160166
yield ExecutionResult(
161167
data=None, errors=self.process_errors(error_payload)

src/tests/http/clients/chalice.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import urllib.parse
44
from io import BytesIO
55
from json import dumps
6-
from typing import Any, Optional, Union
6+
from typing import Any, Optional
77
from typing_extensions import Literal
88

99
from graphql import ExecutionResult
@@ -84,7 +84,7 @@ async def _graphql_request(
8484
headers: Optional[dict[str, str]] = None,
8585
extensions: Optional[dict[str, Any]] = None,
8686
**kwargs: Any,
87-
) -> Response:
87+
) -> Response:
8888
body = self._build_body(
8989
query=query,
9090
operation_name=operation_name,

src/tests/http/test_upload.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import contextlib
21
import json
32
from io import BytesIO
43

src/tests/test/test_client_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
class DummyClient(BaseGraphQLTestClient):
1010
def request(self, body, headers=None, files=None):
11-
return types.SimpleNamespace(content=json.dumps(body).encode(), json=lambda: body)
11+
return types.SimpleNamespace(
12+
content=json.dumps(body).encode(), json=lambda: body
13+
)
1214

1315

1416
def test_build_body_with_variables_and_files():

src/tests/test/test_runtime.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,58 @@
11
import pytest
22
from graphql import (
33
ExecutionResult,
4+
GraphQLError,
45
GraphQLField,
56
GraphQLObjectType,
67
GraphQLSchema,
78
GraphQLString,
8-
GraphQLError,
99
parse,
1010
)
1111

12-
import graphql_server.runtime as runtime
13-
12+
from graphql_server import runtime
1413

1514
schema = GraphQLSchema(
16-
query=GraphQLObjectType('Query', {'hello': GraphQLField(GraphQLString)})
15+
query=GraphQLObjectType("Query", {"hello": GraphQLField(GraphQLString)})
1716
)
1817

1918

2019
def test_validate_document_with_rules():
2120
from graphql.validation.rules.no_unused_fragments import NoUnusedFragmentsRule
2221

23-
doc = parse('query Test { hello }')
22+
doc = parse("query Test { hello }")
2423
assert runtime.validate_document(schema, doc, (NoUnusedFragmentsRule,)) == []
2524

2625

2726
def test_get_custom_context_kwargs(monkeypatch):
28-
assert runtime._get_custom_context_kwargs({'a': 1}) == {'operation_extensions': {'a': 1}}
29-
monkeypatch.setattr(runtime, 'IS_GQL_33', False)
27+
assert runtime._get_custom_context_kwargs({"a": 1}) == {
28+
"operation_extensions": {"a": 1}
29+
}
30+
monkeypatch.setattr(runtime, "IS_GQL_33", False)
3031
try:
31-
assert runtime._get_custom_context_kwargs({'a': 1}) == {}
32+
assert runtime._get_custom_context_kwargs({"a": 1}) == {}
3233
finally:
33-
monkeypatch.setattr(runtime, 'IS_GQL_33', True)
34+
monkeypatch.setattr(runtime, "IS_GQL_33", True)
3435

3536

3637
def test_get_operation_type_multiple_operations():
37-
doc = parse('query A{hello} query B{hello}')
38+
doc = parse("query A{hello} query B{hello}")
3839
with pytest.raises(Exception):
3940
runtime._get_operation_type(doc)
4041

4142

4243
def test_parse_and_validate_document_node():
43-
doc = parse('query Q { hello }')
44+
doc = parse("query Q { hello }")
4445
res = runtime._parse_and_validate(schema, doc, None)
4546
assert res == doc
4647

4748

4849
def test_introspect_success_and_failure(monkeypatch):
4950
data = runtime.introspect(schema)
50-
assert '__schema' in data
51+
assert "__schema" in data
5152

5253
def fake_execute_sync(schema, query):
53-
return ExecutionResult(data=None, errors=[GraphQLError('boom')])
54+
return ExecutionResult(data=None, errors=[GraphQLError("boom")])
5455

55-
monkeypatch.setattr(runtime, 'execute_sync', fake_execute_sync)
56+
monkeypatch.setattr(runtime, "execute_sync", fake_execute_sync)
5657
with pytest.raises(ValueError):
5758
runtime.introspect(schema)

src/tests/types/test_unset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ def test_deprecated_is_unset_and_getattr():
1414
with pytest.warns(DeprecationWarning):
1515
assert unset.is_unset(unset.UNSET)
1616
with pytest.raises(AttributeError):
17-
getattr(unset, "missing")
17+
unset.missing

src/tests/utils/test_debug.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
import pytest
44

5-
from graphql_server.utils.debug import GraphQLJSONEncoder, pretty_print_graphql_operation
5+
from graphql_server.utils.debug import (
6+
GraphQLJSONEncoder,
7+
pretty_print_graphql_operation,
8+
)
69

710

811
def test_graphql_json_encoder_default():

src/tests/websockets/test_graphql_transport_ws.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ async def test_duplicated_operation_ids(ws: WebSocketClient):
423423

424424
async def test_reused_operation_ids(ws: WebSocketClient):
425425
"""Test that an operation id can be reused after it has been
426-
previously used for a completed operation.
426+
previously used for a completed operation.
427427
"""
428428
# Use sub1 as an id for an operation
429429
await ws.send_message(

0 commit comments

Comments
 (0)