Update dependencies, reformat changes with black

This commit is contained in:
Christoph Zwerschke 2019-08-01 19:24:52 +02:00 committed by Mel van Londen
parent b3b9b4fc9e
commit 55c7a67275
18 changed files with 68 additions and 69 deletions

View File

@ -23,6 +23,6 @@ repos:
- id: black
language_version: python3
- repo: https://github.com/PyCQA/flake8
rev: 3.7.7
rev: 3.7.8
hooks:
- id: flake8

View File

@ -45,8 +45,11 @@ class PageInfo(ObjectType):
def page_info_adapter(startCursor, endCursor, hasPreviousPage, hasNextPage):
"""Adapter for creating PageInfo instances"""
return PageInfo(
start_cursor=startCursor, end_cursor=endCursor,
has_previous_page=hasPreviousPage, has_next_page=hasNextPage)
start_cursor=startCursor,
end_cursor=endCursor,
has_previous_page=hasPreviousPage,
has_next_page=hasNextPage,
)
class ConnectionOptions(ObjectTypeOptions):

View File

@ -29,9 +29,7 @@ class ClientIDMutation(Mutation):
cls.Input = type(
"{}Input".format(base_name),
bases,
dict(
input_fields, client_mutation_id=String(name="clientMutationId")
),
dict(input_fields, client_mutation_id=String(name="clientMutationId")),
)
arguments = dict(

View File

@ -71,9 +71,7 @@ class AbstractNode(Interface):
@classmethod
def __init_subclass_with_meta__(cls, **options):
_meta = InterfaceOptions(cls)
_meta.fields = {
'id': GlobalID(cls, description="The ID of the object")
}
_meta.fields = {"id": GlobalID(cls, description="The ID of the object")}
super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)

View File

@ -134,7 +134,9 @@ async def test_respects_an_overly_large_last():
@mark.asyncio
async def test_respects_first_and_after():
await check('first: 2, after: "{}"'.format(cursor_for("B")), "CD", has_next_page=True)
await check(
'first: 2, after: "{}"'.format(cursor_for("B")), "CD", has_next_page=True
)
@mark.asyncio
@ -144,7 +146,9 @@ async def test_respects_first_and_after_with_long_first():
@mark.asyncio
async def test_respects_last_and_before():
await check('last: 2, before: "{}"'.format(cursor_for("D")), "BC", has_previous_page=True)
await check(
'last: 2, before: "{}"'.format(cursor_for("D")), "BC", has_previous_page=True
)
@mark.asyncio

View File

@ -72,9 +72,9 @@ def test_subclassed_node_query():
assert not executed.errors
assert executed.data == {
"node": {
"shared": "1",
"extraField": "extra field info.",
"somethingElse": "----"
"shared": "1",
"extraField": "extra field info.",
"somethingElse": "----",
}
}
@ -144,18 +144,18 @@ def test_node_field_only_lazy_type_wrong():
def test_str_schema():
assert (str(schema) == dedent(
assert str(schema) == dedent(
'''
schema {
query: RootQuery
}
type MyNode implements Node {
"""The ID of the object"""
id: ID!
name: String
}
type MyOtherNode implements Node {
"""The ID of the object"""
id: ID!
@ -163,24 +163,24 @@ def test_str_schema():
somethingElse: String
extraField: String
}
"""An object with an ID"""
interface Node {
"""The ID of the object"""
id: ID!
}
type RootQuery {
first: String
"""The ID of the object"""
node(id: ID!): Node
"""The ID of the object"""
onlyNode(id: ID!): MyNode
"""The ID of the object"""
onlyNodeLazy(id: ID!): MyNode
}
''')
'''
)

View File

@ -53,43 +53,43 @@ graphql_schema = schema.graphql_schema
def test_str_schema_correct():
assert (str(schema) == dedent(
assert str(schema) == dedent(
'''
schema {
query: RootQuery
}
interface BasePhoto {
"""The width of the photo in pixels"""
width: Int
}
interface Node {
"""The ID of the object"""
id: ID!
}
type Photo implements Node & BasePhoto {
"""The ID of the object"""
id: ID!
"""The width of the photo in pixels"""
width: Int
}
type RootQuery {
"""The ID of the object"""
node(id: ID!): Node
}
type User implements Node {
"""The ID of the object"""
id: ID!
"""The full name of the user"""
name: String
}
''')
'''
)

View File

@ -1,6 +1,6 @@
from functools import partial
from pytest import raises
from pytest import raises
from ..argument import Argument, to_arguments
from ..field import Field

View File

@ -85,7 +85,8 @@ def test_bad_datetime_query():
error = result.errors[0]
assert isinstance(error, GraphQLError)
assert error.message == (
"Expected type DateTime, found \"Some string that's not a datetime\".")
'Expected type DateTime, found "Some string that\'s not a datetime".'
)
assert result.data is None
@ -97,7 +98,8 @@ def test_bad_date_query():
error = result.errors[0]
assert isinstance(error, GraphQLError)
assert error.message == (
"Expected type Date, found \"Some string that's not a date\".")
'Expected type Date, found "Some string that\'s not a date".'
)
assert result.data is None
@ -109,7 +111,8 @@ def test_bad_time_query():
error = result.errors[0]
assert isinstance(error, GraphQLError)
assert error.message == (
"Expected type Time, found \"Some string that's not a time\".")
'Expected type Time, found "Some string that\'s not a time".'
)
assert result.data is None

View File

@ -85,10 +85,14 @@ def test_enum_from_builtin_enum_accepts_lambda_description():
episode = schema.get_type("PyEpisode")
assert episode.description == "StarWars Episodes"
assert [(name, value.description, value.deprecation_reason)
for name, value in episode.values.items()] == [
('NEWHOPE', 'New Hope Episode', 'meh'),
('EMPIRE', 'Other', None), ('JEDI', 'Other', None)]
assert [
(name, value.description, value.deprecation_reason)
for name, value in episode.values.items()
] == [
("NEWHOPE", "New Hope Episode", "meh"),
("EMPIRE", "Other", None),
("JEDI", "Other", None),
]
def test_enum_from_python3_enum_uses_enum_doc():

View File

@ -146,11 +146,7 @@ def test_parent_container_get_fields():
def test_parent_container_interface_get_fields():
assert list(ContainerWithInterface._meta.fields) == [
"ifield",
"field1",
"field2",
]
assert list(ContainerWithInterface._meta.fields) == ["ifield", "field1", "field2"]
def test_objecttype_as_container_only_args():

View File

@ -263,7 +263,8 @@ def test_query_input_field():
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
assert not result.errors
assert result.data == {
"test": '["Source!",{"a_input":{"a_field":"String!","recursive_field":null}}]'}
"test": '["Source!",{"a_input":{"a_field":"String!","recursive_field":null}}]'
}
result = test_schema.execute(
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
@ -271,7 +272,7 @@ def test_query_input_field():
assert not result.errors
assert result.data == {
"test": '["Source!",{"a_input":{"a_field":null,"recursive_field":'
'{"a_field":"String!","recursive_field":null}}}]'
'{"a_field":"String!","recursive_field":null}}}]'
}

View File

@ -42,7 +42,7 @@ def test_schema_str():
type MyOtherType {
field: String
}
type Query {
inner: MyOtherType
}

View File

@ -53,10 +53,10 @@ def test_enum():
assert graphql_enum.name == "MyEnum"
assert graphql_enum.description == "Description"
assert graphql_enum.values == {
'foo': GraphQLEnumValue(
"foo": GraphQLEnumValue(
value=1, description="Description foo=1", deprecation_reason="Is deprecated"
),
'bar': GraphQLEnumValue(value=2, description="Description bar=2"),
"bar": GraphQLEnumValue(value=2, description="Description bar=2"),
}
@ -230,11 +230,7 @@ def test_objecttype_camelcase():
foo_field = fields["fooBar"]
assert isinstance(foo_field, GraphQLField)
assert foo_field.args == {
"barFoo": GraphQLArgument(
GraphQLString,
default_value=None,
out_name="bar_foo"
)
"barFoo": GraphQLArgument(GraphQLString, default_value=None, out_name="bar_foo")
}
@ -257,9 +253,7 @@ def test_objecttype_camelcase_disabled():
assert isinstance(foo_field, GraphQLField)
assert foo_field.args == {
"bar_foo": GraphQLArgument(
GraphQLString,
default_value=None,
out_name="bar_foo"
GraphQLString, default_value=None, out_name="bar_foo"
)
}

View File

@ -42,11 +42,7 @@ from ..crunch import crunch
],
[
"complex object",
{
"a": True,
"b": [1, 2, 3],
"c": {"a": True, "b": [1, 2, 3]},
},
{"a": True, "b": [1, 2, 3], "c": {"a": True, "b": [1, 2, 3]}},
[True, 1, 2, 3, [1, 2, 3], {"a": 0, "b": 4}, {"a": 0, "b": 4, "c": 5}],
],
],

View File

@ -109,7 +109,7 @@ async def test_connection_async():
}
}
}
""",
"""
)
assert not result.errors

View File

@ -66,7 +66,7 @@ schema = Schema(query=RootQuery, mutation=Mutation)
@mark.asyncio
async def test_node_query_promise():
executed = await schema.execute_async(
'mutation a { sayPromise(input: {what:"hello", clientMutationId:"1"}) { phrase } }',
'mutation a { sayPromise(input: {what:"hello", clientMutationId:"1"}) { phrase } }'
)
assert not executed.errors
assert executed.data == {"sayPromise": {"phrase": "hello"}}
@ -75,7 +75,7 @@ async def test_node_query_promise():
@mark.asyncio
async def test_edge_query():
executed = await schema.execute_async(
'mutation a { other(input: {clientMutationId:"1"}) { clientMutationId, myNodeEdge { cursor node { name }} } }',
'mutation a { other(input: {clientMutationId:"1"}) { clientMutationId, myNodeEdge { cursor node { name }} } }'
)
assert not executed.errors
assert dict(executed.data) == {

View File

@ -22,14 +22,16 @@ commands =
[testenv:mypy]
basepython=python3.6
deps =
mypy
mypy>=0.720
commands =
mypy graphene
[testenv:flake8]
deps = flake8
basepython=python3.6
deps =
flake8>=3.7,<4
commands =
pip install -e .
pip install --pre -e .
flake8 graphene
[pytest]