Skip to content

Commit

Permalink
Update dependencies, reformat changes with black
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito authored and mvanlonden committed Aug 9, 2019
1 parent 88507c7 commit d9c9b90
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 5 additions & 2 deletions graphene/relay/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ class Meta:
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):
Expand Down
4 changes: 1 addition & 3 deletions graphene/relay/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ def __init_subclass_with_meta__(
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(
Expand Down
4 changes: 1 addition & 3 deletions graphene/relay/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ class Meta:
@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)


Expand Down
8 changes: 6 additions & 2 deletions graphene/relay/tests/test_connection_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions graphene/relay/tests/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": "----",
}
}

Expand Down Expand Up @@ -144,43 +144,43 @@ 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!
shared: String
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
}
''')
'''
)
18 changes: 9 additions & 9 deletions graphene/relay/tests/test_node_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,43 +53,43 @@ class RootQuery(ObjectType):


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
}
''')
'''
)


Expand Down
2 changes: 1 addition & 1 deletion graphene/types/tests/test_argument.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions graphene/types/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand All @@ -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


Expand Down
12 changes: 8 additions & 4 deletions graphene/types/tests/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,14 @@ class Query(ObjectType):
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():
Expand Down
6 changes: 1 addition & 5 deletions graphene/types/tests/test_objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
5 changes: 3 additions & 2 deletions graphene/types/tests/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,16 @@ def resolve_test(self, info, **args):
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!"
)
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}}}]'
}


Expand Down
2 changes: 1 addition & 1 deletion graphene/types/tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_schema_str():
type MyOtherType {
field: String
}
type Query {
inner: MyOtherType
}
Expand Down
14 changes: 4 additions & 10 deletions graphene/types/tests/test_type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def deprecation_reason(self):
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"),
}


Expand Down Expand Up @@ -230,11 +230,7 @@ class MyObjectType(ObjectType):
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")
}


Expand All @@ -257,9 +253,7 @@ class MyObjectType(ObjectType):
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"
)
}

Expand Down
6 changes: 1 addition & 5 deletions graphene/utils/tests/test_crunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
],
[
"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}],
],
],
Expand Down
2 changes: 1 addition & 1 deletion tests_asyncio/test_relay_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async def test_connection_async():
}
}
}
""",
"""
)

assert not result.errors
Expand Down
4 changes: 2 additions & 2 deletions tests_asyncio/test_relay_mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Mutation(ObjectType):
@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"}}
Expand All @@ -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) == {
Expand Down
8 changes: 5 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ commands =
[testenv:mypy]
basepython=python3.7
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]

0 comments on commit d9c9b90

Please sign in to comment.