From 55c7a67275f88ed3f284bb632d32849076d06b78 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Thu, 1 Aug 2019 19:24:52 +0200 Subject: [PATCH] Update dependencies, reformat changes with black --- .pre-commit-config.yaml | 2 +- graphene/relay/connection.py | 7 ++++-- graphene/relay/mutation.py | 4 +--- graphene/relay/node.py | 4 +--- graphene/relay/tests/test_connection_query.py | 8 +++++-- graphene/relay/tests/test_node.py | 24 +++++++++---------- graphene/relay/tests/test_node_custom.py | 18 +++++++------- graphene/types/tests/test_argument.py | 2 +- graphene/types/tests/test_datetime.py | 9 ++++--- graphene/types/tests/test_enum.py | 12 ++++++---- graphene/types/tests/test_objecttype.py | 6 +---- graphene/types/tests/test_query.py | 5 ++-- graphene/types/tests/test_schema.py | 2 +- graphene/types/tests/test_type_map.py | 14 ++++------- graphene/utils/tests/test_crunch.py | 6 +---- tests_asyncio/test_relay_connection.py | 2 +- tests_asyncio/test_relay_mutation.py | 4 ++-- tox.ini | 8 ++++--- 18 files changed, 68 insertions(+), 69 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 227da33c..7aa72001 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/graphene/relay/connection.py b/graphene/relay/connection.py index 464c68af..f6d3296d 100644 --- a/graphene/relay/connection.py +++ b/graphene/relay/connection.py @@ -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): diff --git a/graphene/relay/mutation.py b/graphene/relay/mutation.py index bb27855f..fce0c598 100644 --- a/graphene/relay/mutation.py +++ b/graphene/relay/mutation.py @@ -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( diff --git a/graphene/relay/node.py b/graphene/relay/node.py index 79c34ffc..54423bbb 100644 --- a/graphene/relay/node.py +++ b/graphene/relay/node.py @@ -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) diff --git a/graphene/relay/tests/test_connection_query.py b/graphene/relay/tests/test_connection_query.py index 7e6f2c4d..e109067b 100644 --- a/graphene/relay/tests/test_connection_query.py +++ b/graphene/relay/tests/test_connection_query.py @@ -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 diff --git a/graphene/relay/tests/test_node.py b/graphene/relay/tests/test_node.py index 66ad12b4..c43ee1ed 100644 --- a/graphene/relay/tests/test_node.py +++ b/graphene/relay/tests/test_node.py @@ -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 } - ''') + ''' ) diff --git a/graphene/relay/tests/test_node_custom.py b/graphene/relay/tests/test_node_custom.py index 967bbead..773be48f 100644 --- a/graphene/relay/tests/test_node_custom.py +++ b/graphene/relay/tests/test_node_custom.py @@ -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 } - ''') + ''' ) diff --git a/graphene/types/tests/test_argument.py b/graphene/types/tests/test_argument.py index eee50892..db4d6c24 100644 --- a/graphene/types/tests/test_argument.py +++ b/graphene/types/tests/test_argument.py @@ -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 diff --git a/graphene/types/tests/test_datetime.py b/graphene/types/tests/test_datetime.py index 4caa79cf..bfd56c6c 100644 --- a/graphene/types/tests/test_datetime.py +++ b/graphene/types/tests/test_datetime.py @@ -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 diff --git a/graphene/types/tests/test_enum.py b/graphene/types/tests/test_enum.py index cf7227e4..1c5bdb38 100644 --- a/graphene/types/tests/test_enum.py +++ b/graphene/types/tests/test_enum.py @@ -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(): diff --git a/graphene/types/tests/test_objecttype.py b/graphene/types/tests/test_objecttype.py index a3f331fe..25025e4d 100644 --- a/graphene/types/tests/test_objecttype.py +++ b/graphene/types/tests/test_objecttype.py @@ -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(): diff --git a/graphene/types/tests/test_query.py b/graphene/types/tests/test_query.py index 259e6b02..004d53c8 100644 --- a/graphene/types/tests/test_query.py +++ b/graphene/types/tests/test_query.py @@ -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}}}]' } diff --git a/graphene/types/tests/test_schema.py b/graphene/types/tests/test_schema.py index d0990e61..29581122 100644 --- a/graphene/types/tests/test_schema.py +++ b/graphene/types/tests/test_schema.py @@ -42,7 +42,7 @@ def test_schema_str(): type MyOtherType { field: String } - + type Query { inner: MyOtherType } diff --git a/graphene/types/tests/test_type_map.py b/graphene/types/tests/test_type_map.py index ba7e2072..0ef3af1b 100644 --- a/graphene/types/tests/test_type_map.py +++ b/graphene/types/tests/test_type_map.py @@ -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" ) } diff --git a/graphene/utils/tests/test_crunch.py b/graphene/utils/tests/test_crunch.py index 2a4a0ce4..92d0b1b0 100644 --- a/graphene/utils/tests/test_crunch.py +++ b/graphene/utils/tests/test_crunch.py @@ -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}], ], ], diff --git a/tests_asyncio/test_relay_connection.py b/tests_asyncio/test_relay_connection.py index 67ee2ee4..b139f6a3 100644 --- a/tests_asyncio/test_relay_connection.py +++ b/tests_asyncio/test_relay_connection.py @@ -109,7 +109,7 @@ async def test_connection_async(): } } } - """, + """ ) assert not result.errors diff --git a/tests_asyncio/test_relay_mutation.py b/tests_asyncio/test_relay_mutation.py index 011557d5..7b083dbf 100644 --- a/tests_asyncio/test_relay_mutation.py +++ b/tests_asyncio/test_relay_mutation.py @@ -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) == { diff --git a/tox.ini b/tox.ini index 5529dc23..dad55b87 100644 --- a/tox.ini +++ b/tox.ini @@ -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]