mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
Avoid various deprecation warnings
This commit is contained in:
parent
8b07dbac9b
commit
a02ea47681
|
@ -1,5 +1,5 @@
|
||||||
import re
|
import re
|
||||||
from collections import Iterable
|
from collections.abc import Iterable
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from graphql_relay import connection_from_array
|
from graphql_relay import connection_from_array
|
||||||
|
|
|
@ -21,7 +21,7 @@ class CreatePostResult(graphene.Union):
|
||||||
|
|
||||||
|
|
||||||
class CreatePost(graphene.Mutation):
|
class CreatePost(graphene.Mutation):
|
||||||
class Input:
|
class Arguments:
|
||||||
text = graphene.String(required=True)
|
text = graphene.String(required=True)
|
||||||
|
|
||||||
result = graphene.Field(CreatePostResult)
|
result = graphene.Field(CreatePostResult)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import inspect
|
import inspect
|
||||||
from collections import Mapping, OrderedDict
|
from collections.abc import Mapping
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from .argument import Argument, to_arguments
|
from .argument import Argument, to_arguments
|
||||||
|
@ -59,7 +59,7 @@ class Field(MountedType):
|
||||||
|
|
||||||
self.name = name
|
self.name = name
|
||||||
self._type = type
|
self._type = type
|
||||||
self.args = to_arguments(args or OrderedDict(), extra_args)
|
self.args = to_arguments(args or {}, extra_args)
|
||||||
if source:
|
if source:
|
||||||
resolver = partial(source_resolver, source)
|
resolver = partial(source_resolver, source)
|
||||||
self.resolver = resolver
|
self.resolver = resolver
|
||||||
|
|
|
@ -47,7 +47,7 @@ class Mutation(ObjectType):
|
||||||
warn_deprecation(
|
warn_deprecation(
|
||||||
(
|
(
|
||||||
"Please use {name}.Arguments instead of {name}.Input."
|
"Please use {name}.Arguments instead of {name}.Input."
|
||||||
"Input is now only used in ClientMutationID.\n"
|
" Input is now only used in ClientMutationID.\n"
|
||||||
"Read more:"
|
"Read more:"
|
||||||
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
|
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
|
||||||
).format(name=cls.__name__)
|
).format(name=cls.__name__)
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from .. import abstracttype
|
from pytest import deprecated_call
|
||||||
|
|
||||||
from ..abstracttype import AbstractType
|
from ..abstracttype import AbstractType
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
|
@ -14,21 +15,22 @@ class MyScalar(UnmountedType):
|
||||||
return MyType
|
return MyType
|
||||||
|
|
||||||
|
|
||||||
def test_abstract_objecttype_warn_deprecation(mocker):
|
def test_abstract_objecttype_warn_deprecation():
|
||||||
mocker.patch.object(abstracttype, "warn_deprecation")
|
with deprecated_call():
|
||||||
|
|
||||||
class MyAbstractType(AbstractType):
|
# noinspection PyUnusedLocal
|
||||||
field1 = MyScalar()
|
class MyAbstractType(AbstractType):
|
||||||
|
field1 = MyScalar()
|
||||||
assert abstracttype.warn_deprecation.called
|
|
||||||
|
|
||||||
|
|
||||||
def test_generate_objecttype_inherit_abstracttype():
|
def test_generate_objecttype_inherit_abstracttype():
|
||||||
class MyAbstractType(AbstractType):
|
with deprecated_call():
|
||||||
field1 = MyScalar()
|
|
||||||
|
|
||||||
class MyObjectType(ObjectType, MyAbstractType):
|
class MyAbstractType(AbstractType):
|
||||||
field2 = MyScalar()
|
field1 = MyScalar()
|
||||||
|
|
||||||
|
class MyObjectType(ObjectType, MyAbstractType):
|
||||||
|
field2 = MyScalar()
|
||||||
|
|
||||||
assert MyObjectType._meta.description is None
|
assert MyObjectType._meta.description is None
|
||||||
assert MyObjectType._meta.interfaces == ()
|
assert MyObjectType._meta.interfaces == ()
|
||||||
|
|
|
@ -182,9 +182,10 @@ def test_bad_variables(sample_date, sample_datetime, sample_time):
|
||||||
),
|
),
|
||||||
variables={"input": input_},
|
variables={"input": input_},
|
||||||
)
|
)
|
||||||
assert result.errors and len(result.errors) == 1
|
|
||||||
# when `input` is not JSON serializable formatting the error message in
|
# when `input` is not JSON serializable formatting the error message in
|
||||||
# `graphql.utils.is_valid_value` line 79 fails with a TypeError
|
# `graphql.utils.is_valid_value` line 79 fails with a TypeError
|
||||||
|
assert isinstance(result.errors, list)
|
||||||
|
assert len(result.errors) == 1
|
||||||
assert isinstance(result.errors[0], GraphQLError)
|
assert isinstance(result.errors[0], GraphQLError)
|
||||||
assert result.data is None
|
assert result.data is None
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import json
|
import json
|
||||||
from collections import Mapping
|
from collections.abc import Mapping
|
||||||
|
|
||||||
|
|
||||||
def to_key(value):
|
def to_key(value):
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from collections import Mapping
|
from collections.abc import Mapping
|
||||||
|
|
||||||
|
|
||||||
def deflate(node, index=None, path=None):
|
def deflate(node, index=None, path=None):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user