mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
Update dependencies, reformat changes with black
This commit is contained in:
parent
b3b9b4fc9e
commit
55c7a67275
|
@ -23,6 +23,6 @@ repos:
|
||||||
- id: black
|
- id: black
|
||||||
language_version: python3
|
language_version: python3
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.7.7
|
rev: 3.7.8
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
|
|
|
@ -45,8 +45,11 @@ class PageInfo(ObjectType):
|
||||||
def page_info_adapter(startCursor, endCursor, hasPreviousPage, hasNextPage):
|
def page_info_adapter(startCursor, endCursor, hasPreviousPage, hasNextPage):
|
||||||
"""Adapter for creating PageInfo instances"""
|
"""Adapter for creating PageInfo instances"""
|
||||||
return PageInfo(
|
return PageInfo(
|
||||||
start_cursor=startCursor, end_cursor=endCursor,
|
start_cursor=startCursor,
|
||||||
has_previous_page=hasPreviousPage, has_next_page=hasNextPage)
|
end_cursor=endCursor,
|
||||||
|
has_previous_page=hasPreviousPage,
|
||||||
|
has_next_page=hasNextPage,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class ConnectionOptions(ObjectTypeOptions):
|
class ConnectionOptions(ObjectTypeOptions):
|
||||||
|
|
|
@ -29,9 +29,7 @@ class ClientIDMutation(Mutation):
|
||||||
cls.Input = type(
|
cls.Input = type(
|
||||||
"{}Input".format(base_name),
|
"{}Input".format(base_name),
|
||||||
bases,
|
bases,
|
||||||
dict(
|
dict(input_fields, client_mutation_id=String(name="clientMutationId")),
|
||||||
input_fields, client_mutation_id=String(name="clientMutationId")
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
arguments = dict(
|
arguments = dict(
|
||||||
|
|
|
@ -71,9 +71,7 @@ class AbstractNode(Interface):
|
||||||
@classmethod
|
@classmethod
|
||||||
def __init_subclass_with_meta__(cls, **options):
|
def __init_subclass_with_meta__(cls, **options):
|
||||||
_meta = InterfaceOptions(cls)
|
_meta = InterfaceOptions(cls)
|
||||||
_meta.fields = {
|
_meta.fields = {"id": GlobalID(cls, description="The ID of the object")}
|
||||||
'id': GlobalID(cls, description="The ID of the object")
|
|
||||||
}
|
|
||||||
super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
super(AbstractNode, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,9 @@ async def test_respects_an_overly_large_last():
|
||||||
|
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
async def test_respects_first_and_after():
|
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
|
@mark.asyncio
|
||||||
|
@ -144,7 +146,9 @@ async def test_respects_first_and_after_with_long_first():
|
||||||
|
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
async def test_respects_last_and_before():
|
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
|
@mark.asyncio
|
||||||
|
|
|
@ -72,9 +72,9 @@ def test_subclassed_node_query():
|
||||||
assert not executed.errors
|
assert not executed.errors
|
||||||
assert executed.data == {
|
assert executed.data == {
|
||||||
"node": {
|
"node": {
|
||||||
"shared": "1",
|
"shared": "1",
|
||||||
"extraField": "extra field info.",
|
"extraField": "extra field info.",
|
||||||
"somethingElse": "----"
|
"somethingElse": "----",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,18 +144,18 @@ def test_node_field_only_lazy_type_wrong():
|
||||||
|
|
||||||
|
|
||||||
def test_str_schema():
|
def test_str_schema():
|
||||||
assert (str(schema) == dedent(
|
assert str(schema) == dedent(
|
||||||
'''
|
'''
|
||||||
schema {
|
schema {
|
||||||
query: RootQuery
|
query: RootQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
type MyNode implements Node {
|
type MyNode implements Node {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
id: ID!
|
id: ID!
|
||||||
name: String
|
name: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type MyOtherNode implements Node {
|
type MyOtherNode implements Node {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
id: ID!
|
id: ID!
|
||||||
|
@ -163,24 +163,24 @@ def test_str_schema():
|
||||||
somethingElse: String
|
somethingElse: String
|
||||||
extraField: String
|
extraField: String
|
||||||
}
|
}
|
||||||
|
|
||||||
"""An object with an ID"""
|
"""An object with an ID"""
|
||||||
interface Node {
|
interface Node {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
id: ID!
|
id: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
type RootQuery {
|
type RootQuery {
|
||||||
first: String
|
first: String
|
||||||
|
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
node(id: ID!): Node
|
node(id: ID!): Node
|
||||||
|
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
onlyNode(id: ID!): MyNode
|
onlyNode(id: ID!): MyNode
|
||||||
|
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
onlyNodeLazy(id: ID!): MyNode
|
onlyNodeLazy(id: ID!): MyNode
|
||||||
}
|
}
|
||||||
''')
|
'''
|
||||||
)
|
)
|
||||||
|
|
|
@ -53,43 +53,43 @@ graphql_schema = schema.graphql_schema
|
||||||
|
|
||||||
|
|
||||||
def test_str_schema_correct():
|
def test_str_schema_correct():
|
||||||
assert (str(schema) == dedent(
|
assert str(schema) == dedent(
|
||||||
'''
|
'''
|
||||||
schema {
|
schema {
|
||||||
query: RootQuery
|
query: RootQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
interface BasePhoto {
|
interface BasePhoto {
|
||||||
"""The width of the photo in pixels"""
|
"""The width of the photo in pixels"""
|
||||||
width: Int
|
width: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Node {
|
interface Node {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
id: ID!
|
id: ID!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Photo implements Node & BasePhoto {
|
type Photo implements Node & BasePhoto {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
"""The width of the photo in pixels"""
|
"""The width of the photo in pixels"""
|
||||||
width: Int
|
width: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
type RootQuery {
|
type RootQuery {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
node(id: ID!): Node
|
node(id: ID!): Node
|
||||||
}
|
}
|
||||||
|
|
||||||
type User implements Node {
|
type User implements Node {
|
||||||
"""The ID of the object"""
|
"""The ID of the object"""
|
||||||
id: ID!
|
id: ID!
|
||||||
|
|
||||||
"""The full name of the user"""
|
"""The full name of the user"""
|
||||||
name: String
|
name: String
|
||||||
}
|
}
|
||||||
''')
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from pytest import raises
|
from pytest import raises
|
||||||
|
|
||||||
from ..argument import Argument, to_arguments
|
from ..argument import Argument, to_arguments
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
|
|
|
@ -85,7 +85,8 @@ def test_bad_datetime_query():
|
||||||
error = result.errors[0]
|
error = result.errors[0]
|
||||||
assert isinstance(error, GraphQLError)
|
assert isinstance(error, GraphQLError)
|
||||||
assert error.message == (
|
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
|
assert result.data is None
|
||||||
|
|
||||||
|
|
||||||
|
@ -97,7 +98,8 @@ def test_bad_date_query():
|
||||||
error = result.errors[0]
|
error = result.errors[0]
|
||||||
assert isinstance(error, GraphQLError)
|
assert isinstance(error, GraphQLError)
|
||||||
assert error.message == (
|
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
|
assert result.data is None
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +111,8 @@ def test_bad_time_query():
|
||||||
error = result.errors[0]
|
error = result.errors[0]
|
||||||
assert isinstance(error, GraphQLError)
|
assert isinstance(error, GraphQLError)
|
||||||
assert error.message == (
|
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
|
assert result.data is None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,14 @@ def test_enum_from_builtin_enum_accepts_lambda_description():
|
||||||
episode = schema.get_type("PyEpisode")
|
episode = schema.get_type("PyEpisode")
|
||||||
|
|
||||||
assert episode.description == "StarWars Episodes"
|
assert episode.description == "StarWars Episodes"
|
||||||
assert [(name, value.description, value.deprecation_reason)
|
assert [
|
||||||
for name, value in episode.values.items()] == [
|
(name, value.description, value.deprecation_reason)
|
||||||
('NEWHOPE', 'New Hope Episode', 'meh'),
|
for name, value in episode.values.items()
|
||||||
('EMPIRE', 'Other', None), ('JEDI', 'Other', None)]
|
] == [
|
||||||
|
("NEWHOPE", "New Hope Episode", "meh"),
|
||||||
|
("EMPIRE", "Other", None),
|
||||||
|
("JEDI", "Other", None),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def test_enum_from_python3_enum_uses_enum_doc():
|
def test_enum_from_python3_enum_uses_enum_doc():
|
||||||
|
|
|
@ -146,11 +146,7 @@ def test_parent_container_get_fields():
|
||||||
|
|
||||||
|
|
||||||
def test_parent_container_interface_get_fields():
|
def test_parent_container_interface_get_fields():
|
||||||
assert list(ContainerWithInterface._meta.fields) == [
|
assert list(ContainerWithInterface._meta.fields) == ["ifield", "field1", "field2"]
|
||||||
"ifield",
|
|
||||||
"field1",
|
|
||||||
"field2",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def test_objecttype_as_container_only_args():
|
def test_objecttype_as_container_only_args():
|
||||||
|
|
|
@ -263,7 +263,8 @@ def test_query_input_field():
|
||||||
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
|
result = test_schema.execute('{ test(aInput: {aField: "String!"} ) }', "Source!")
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == {
|
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(
|
result = test_schema.execute(
|
||||||
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
|
'{ test(aInput: {recursiveField: {aField: "String!"}}) }', "Source!"
|
||||||
|
@ -271,7 +272,7 @@ def test_query_input_field():
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == {
|
assert result.data == {
|
||||||
"test": '["Source!",{"a_input":{"a_field":null,"recursive_field":'
|
"test": '["Source!",{"a_input":{"a_field":null,"recursive_field":'
|
||||||
'{"a_field":"String!","recursive_field":null}}}]'
|
'{"a_field":"String!","recursive_field":null}}}]'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ def test_schema_str():
|
||||||
type MyOtherType {
|
type MyOtherType {
|
||||||
field: String
|
field: String
|
||||||
}
|
}
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
inner: MyOtherType
|
inner: MyOtherType
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,10 @@ def test_enum():
|
||||||
assert graphql_enum.name == "MyEnum"
|
assert graphql_enum.name == "MyEnum"
|
||||||
assert graphql_enum.description == "Description"
|
assert graphql_enum.description == "Description"
|
||||||
assert graphql_enum.values == {
|
assert graphql_enum.values == {
|
||||||
'foo': GraphQLEnumValue(
|
"foo": GraphQLEnumValue(
|
||||||
value=1, description="Description foo=1", deprecation_reason="Is deprecated"
|
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"]
|
foo_field = fields["fooBar"]
|
||||||
assert isinstance(foo_field, GraphQLField)
|
assert isinstance(foo_field, GraphQLField)
|
||||||
assert foo_field.args == {
|
assert foo_field.args == {
|
||||||
"barFoo": GraphQLArgument(
|
"barFoo": GraphQLArgument(GraphQLString, default_value=None, out_name="bar_foo")
|
||||||
GraphQLString,
|
|
||||||
default_value=None,
|
|
||||||
out_name="bar_foo"
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -257,9 +253,7 @@ def test_objecttype_camelcase_disabled():
|
||||||
assert isinstance(foo_field, GraphQLField)
|
assert isinstance(foo_field, GraphQLField)
|
||||||
assert foo_field.args == {
|
assert foo_field.args == {
|
||||||
"bar_foo": GraphQLArgument(
|
"bar_foo": GraphQLArgument(
|
||||||
GraphQLString,
|
GraphQLString, default_value=None, out_name="bar_foo"
|
||||||
default_value=None,
|
|
||||||
out_name="bar_foo"
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,11 +42,7 @@ from ..crunch import crunch
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"complex object",
|
"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}],
|
[True, 1, 2, 3, [1, 2, 3], {"a": 0, "b": 4}, {"a": 0, "b": 4, "c": 5}],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
|
@ -109,7 +109,7 @@ async def test_connection_async():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""",
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
|
|
|
@ -66,7 +66,7 @@ schema = Schema(query=RootQuery, mutation=Mutation)
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
async def test_node_query_promise():
|
async def test_node_query_promise():
|
||||||
executed = await schema.execute_async(
|
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 not executed.errors
|
||||||
assert executed.data == {"sayPromise": {"phrase": "hello"}}
|
assert executed.data == {"sayPromise": {"phrase": "hello"}}
|
||||||
|
@ -75,7 +75,7 @@ async def test_node_query_promise():
|
||||||
@mark.asyncio
|
@mark.asyncio
|
||||||
async def test_edge_query():
|
async def test_edge_query():
|
||||||
executed = await schema.execute_async(
|
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 not executed.errors
|
||||||
assert dict(executed.data) == {
|
assert dict(executed.data) == {
|
||||||
|
|
8
tox.ini
8
tox.ini
|
@ -22,14 +22,16 @@ commands =
|
||||||
[testenv:mypy]
|
[testenv:mypy]
|
||||||
basepython=python3.6
|
basepython=python3.6
|
||||||
deps =
|
deps =
|
||||||
mypy
|
mypy>=0.720
|
||||||
commands =
|
commands =
|
||||||
mypy graphene
|
mypy graphene
|
||||||
|
|
||||||
[testenv:flake8]
|
[testenv:flake8]
|
||||||
deps = flake8
|
basepython=python3.6
|
||||||
|
deps =
|
||||||
|
flake8>=3.7,<4
|
||||||
commands =
|
commands =
|
||||||
pip install -e .
|
pip install --pre -e .
|
||||||
flake8 graphene
|
flake8 graphene
|
||||||
|
|
||||||
[pytest]
|
[pytest]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user