Skip to content

Update black dev dependency to 22.3.0 #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/code_examples/aiohttp_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ async def main():
# Using `async with` on the client will start a connection on the transport
# and provide a `session` variable to execute queries on this connection
async with Client(
transport=transport, fetch_schema_from_transport=True,
transport=transport,
fetch_schema_from_transport=True,
) as session:

# Execute single query
Expand Down
3 changes: 2 additions & 1 deletion docs/code_examples/appsync/mutation_api_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ async def main():
transport = AIOHTTPTransport(url=url, auth=auth)

async with Client(
transport=transport, fetch_schema_from_transport=False,
transport=transport,
fetch_schema_from_transport=False,
) as session:

query = gql(
Expand Down
3 changes: 2 additions & 1 deletion docs/code_examples/appsync/mutation_iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ async def main():
transport = AIOHTTPTransport(url=url, auth=auth)

async with Client(
transport=transport, fetch_schema_from_transport=False,
transport=transport,
fetch_schema_from_transport=False,
) as session:

query = gql(
Expand Down
4 changes: 3 additions & 1 deletion docs/code_examples/requests_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from gql.transport.requests import RequestsHTTPTransport

transport = RequestsHTTPTransport(
url="https://countries.trevorblades.com/", verify=True, retries=3,
url="https://countries.trevorblades.com/",
verify=True,
retries=3,
)

client = Client(transport=transport, fetch_schema_from_transport=True)
Expand Down
4 changes: 3 additions & 1 deletion docs/code_examples/requests_sync_dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from gql.transport.requests import RequestsHTTPTransport

transport = RequestsHTTPTransport(
url="https://countries.trevorblades.com/", verify=True, retries=3,
url="https://countries.trevorblades.com/",
verify=True,
retries=3,
)

client = Client(transport=transport, fetch_schema_from_transport=True)
Expand Down
3 changes: 2 additions & 1 deletion docs/code_examples/websockets_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ async def main():
# Using `async with` on the client will start a connection on the transport
# and provide a `session` variable to execute queries on this connection
async with Client(
transport=transport, fetch_schema_from_transport=True,
transport=transport,
fetch_schema_from_transport=True,
) as session:

# Execute single query
Expand Down
8 changes: 6 additions & 2 deletions gql/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,15 @@ def get_parser(with_examples: bool = False) -> ArgumentParser:
appsync_auth_group = appsync_group.add_mutually_exclusive_group()

appsync_auth_group.add_argument(
"--api-key", help="Provide an API key for authentication", dest="api_key",
"--api-key",
help="Provide an API key for authentication",
dest="api_key",
)

appsync_auth_group.add_argument(
"--jwt", help="Provide an JSON Web token for authentication", dest="jwt",
"--jwt",
help="Provide an JSON Web token for authentication",
dest="jwt",
)

return parser
Expand Down
23 changes: 17 additions & 6 deletions gql/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ class DSLSelector(ABC):
selection_set: SelectionSetNode

def __init__(
self, *fields: "DSLSelectable", **fields_with_alias: "DSLSelectableWithAlias",
self,
*fields: "DSLSelectable",
**fields_with_alias: "DSLSelectableWithAlias",
):
""":meta private:"""
self.selection_set = SelectionSetNode(selections=())
Expand All @@ -326,7 +328,9 @@ def is_valid_field(self, field: "DSLSelectable") -> bool:
) # pragma: no cover

def select(
self, *fields: "DSLSelectable", **fields_with_alias: "DSLSelectableWithAlias",
self,
*fields: "DSLSelectable",
**fields_with_alias: "DSLSelectableWithAlias",
):
r"""Select the fields which should be added.

Expand Down Expand Up @@ -387,7 +391,9 @@ def executable_ast(self):
) # pragma: no cover

def __init__(
self, *fields: "DSLSelectable", **fields_with_alias: "DSLSelectableWithAlias",
self,
*fields: "DSLSelectable",
**fields_with_alias: "DSLSelectableWithAlias",
):
r"""Given arguments of type :class:`DSLSelectable` containing GraphQL requests,
generate an operation which can be converted to a Document
Expand Down Expand Up @@ -552,7 +558,9 @@ def get_ast_definitions(self) -> Tuple[VariableDefinitionNode, ...]:
"""
return tuple(
VariableDefinitionNode(
type=var.type, variable=var.ast_variable, default_value=None,
type=var.type,
variable=var.ast_variable,
default_value=None,
)
for var in self.variables.values()
if var.type is not None # only variables used
Expand Down Expand Up @@ -889,7 +897,9 @@ class DSLInlineFragment(DSLSelectable, DSLFragmentSelector):
ast_field: InlineFragmentNode

def __init__(
self, *fields: "DSLSelectable", **fields_with_alias: "DSLSelectableWithAlias",
self,
*fields: "DSLSelectable",
**fields_with_alias: "DSLSelectableWithAlias",
):
r"""Initialize the DSLInlineFragment.

Expand Down Expand Up @@ -944,7 +954,8 @@ class DSLFragment(DSLSelectable, DSLFragmentSelector, DSLExecutable):
name: str

def __init__(
self, name: str,
self,
name: str,
):
r"""Initialize the DSLFragment.

Expand Down
6 changes: 4 additions & 2 deletions gql/transport/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ async def execute(
# If we upload files, we will extract the files present in the
# variable_values dict and replace them by null values
nulled_variable_values, files = extract_files(
variables=variable_values, file_classes=self.file_classes,
variables=variable_values,
file_classes=self.file_classes,
)

# Save the nulled variable values in the payload
Expand Down Expand Up @@ -275,7 +276,8 @@ async def execute(
# Add headers for AppSync if requested
if isinstance(self.auth, AppSyncAuthentication):
post_args["headers"] = self.auth.get_headers(
json.dumps(payload), {"content-type": "application/json"},
json.dumps(payload),
{"content-type": "application/json"},
)

if self.session is None:
Expand Down
7 changes: 6 additions & 1 deletion gql/transport/appsync_websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,12 @@ async def _send_query(
"authorization": self.auth.get_headers(serialized_data)
}

await self._send(json.dumps(message, separators=(",", ":"),))
await self._send(
json.dumps(
message,
separators=(",", ":"),
)
)

return query_id

Expand Down
10 changes: 4 additions & 6 deletions gql/transport/async_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
class AsyncTransport:
@abc.abstractmethod
async def connect(self):
"""Coroutine used to create a connection to the specified address
"""
"""Coroutine used to create a connection to the specified address"""
raise NotImplementedError(
"Any AsyncTransport subclass must implement connect method"
) # pragma: no cover

@abc.abstractmethod
async def close(self):
"""Coroutine used to Close an established connection
"""
"""Coroutine used to Close an established connection"""
raise NotImplementedError(
"Any AsyncTransport subclass must implement close method"
) # pragma: no cover
Expand All @@ -28,8 +26,8 @@ async def execute(
variable_values: Optional[Dict[str, Any]] = None,
operation_name: Optional[str] = None,
) -> ExecutionResult:
"""Execute the provided document AST for either a remote or local GraphQL Schema.
"""
"""Execute the provided document AST for either a remote or local GraphQL
Schema."""
raise NotImplementedError(
"Any AsyncTransport subclass must implement execute method"
) # pragma: no cover
Expand Down
22 changes: 13 additions & 9 deletions gql/transport/local_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class LocalSchemaTransport(AsyncTransport):
"""A transport for executing GraphQL queries against a local schema."""

def __init__(
self, schema: GraphQLSchema,
self,
schema: GraphQLSchema,
):
"""Initialize the transport with the given local schema.

Expand All @@ -19,20 +20,20 @@ def __init__(
self.schema = schema

async def connect(self):
"""No connection needed on local transport
"""
"""No connection needed on local transport"""
pass

async def close(self):
"""No close needed on local transport
"""
"""No close needed on local transport"""
pass

async def execute(
self, document: DocumentNode, *args, **kwargs,
self,
document: DocumentNode,
*args,
**kwargs,
) -> ExecutionResult:
"""Execute the provided document AST for on a local GraphQL Schema.
"""
"""Execute the provided document AST for on a local GraphQL Schema."""

result_or_awaitable = execute(self.schema, document, *args, **kwargs)

Expand All @@ -48,7 +49,10 @@ async def execute(
return execution_result

async def subscribe(
self, document: DocumentNode, *args, **kwargs,
self,
document: DocumentNode,
*args,
**kwargs,
) -> AsyncGenerator[ExecutionResult, None]:
"""Send a subscription and receive the results using an async generator

Expand Down
3 changes: 2 additions & 1 deletion gql/transport/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ def execute( # type: ignore
# If we upload files, we will extract the files present in the
# variable_values dict and replace them by null values
nulled_variable_values, files = extract_files(
variables=variable_values, file_classes=self.file_classes,
variables=variable_values,
file_classes=self.file_classes,
)

# Save the nulled variable values in the payload
Expand Down
3 changes: 1 addition & 2 deletions gql/transport/transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def execute(self, document: DocumentNode, *args, **kwargs) -> ExecutionResult:
) # pragma: no cover

def connect(self):
"""Establish a session with the transport.
"""
"""Establish a session with the transport."""
pass # pragma: no cover

def close(self):
Expand Down
6 changes: 2 additions & 4 deletions gql/transport/websockets.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ async def _initialize(self):
await self._send_init_message_and_wait_ack()

async def send_ping(self, payload: Optional[Any] = None) -> None:
"""Send a ping message for the graphql-ws protocol
"""
"""Send a ping message for the graphql-ws protocol"""

ping_message = {"type": "ping"}

Expand All @@ -163,8 +162,7 @@ async def send_ping(self, payload: Optional[Any] = None) -> None:
await self._send(json.dumps(ping_message))

async def send_pong(self, payload: Optional[Any] = None) -> None:
"""Send a pong message for the graphql-ws protocol
"""
"""Send a pong message for the graphql-ws protocol"""

pong_message = {"type": "pong"}

Expand Down
3 changes: 1 addition & 2 deletions gql/transport/websockets_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ async def _after_initialize(self):
pass # pragma: no cover

async def _close_hook(self):
"""Hook to add custom code for subclasses for the connection close
"""
"""Hook to add custom code for subclasses for the connection close"""
pass # pragma: no cover

async def _connection_terminate(self):
Expand Down
15 changes: 10 additions & 5 deletions gql/utilities/get_introspection_query_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,15 @@ def get_introspection_query_ast(
if directive_is_repeatable:
directives.select(ds.__Directive.isRepeatable)
directives.select(
ds.__Directive.locations, ds.__Directive.args.select(fragment_InputValue),
ds.__Directive.locations,
ds.__Directive.args.select(fragment_InputValue),
)

schema.select(directives)

fragment_FullType.select(
ds.__Type.kind, ds.__Type.name,
ds.__Type.kind,
ds.__Type.name,
)
if descriptions:
fragment_FullType.select(ds.__Type.description)
Expand All @@ -81,7 +83,8 @@ def get_introspection_query_ast(
enum_values.select(ds.__EnumValue.description)

enum_values.select(
ds.__EnumValue.isDeprecated, ds.__EnumValue.deprecationReason,
ds.__EnumValue.isDeprecated,
ds.__EnumValue.deprecationReason,
)

fragment_FullType.select(
Expand All @@ -98,11 +101,13 @@ def get_introspection_query_ast(
fragment_InputValue.select(ds.__InputValue.description)

fragment_InputValue.select(
ds.__InputValue.type.select(fragment_TypeRef), ds.__InputValue.defaultValue,
ds.__InputValue.type.select(fragment_TypeRef),
ds.__InputValue.defaultValue,
)

fragment_TypeRef.select(
ds.__Type.kind, ds.__Type.name,
ds.__Type.kind,
ds.__Type.name,
)

if type_recursion_level >= 1:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]

dev_requires = [
"black==19.10b0",
"black==22.3.0",
"check-manifest>=0.42,<1",
"flake8==3.8.1",
"isort==4.3.21",
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,8 @@ async def client_and_graphqlws_server(graphqlws_server):
path = "/graphql"
url = f"ws://{graphqlws_server.hostname}:{graphqlws_server.port}{path}"
sample_transport = WebsocketsTransport(
url=url, subprotocols=[WebsocketsTransport.GRAPHQLWS_SUBPROTOCOL],
url=url,
subprotocols=[WebsocketsTransport.GRAPHQLWS_SUBPROTOCOL],
)

async with Client(transport=sample_transport) as session:
Expand Down
8 changes: 6 additions & 2 deletions tests/custom_scalars/test_enum_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def resolve_list(_root, _info):
queryType = GraphQLObjectType(
name="RootQueryType",
fields={
"all": GraphQLField(GraphQLList(ColorType), resolve=resolve_all,),
"all": GraphQLField(
GraphQLList(ColorType),
resolve=resolve_all,
),
"opposite": GraphQLField(
ColorType,
args={"color": GraphQLArgument(ColorType)},
Expand All @@ -90,7 +93,8 @@ def resolve_list(_root, _info):
resolve=resolve_list_of_list,
),
"list": GraphQLField(
GraphQLNonNull(GraphQLList(ColorType)), resolve=resolve_list,
GraphQLNonNull(GraphQLList(ColorType)),
resolve=resolve_list,
),
},
)
Expand Down
Loading