Avoid various deprecation warnings

This commit is contained in:
Christoph Zwerschke 2019-07-12 21:29:20 +02:00 committed by Mel van Londen
parent 8b07dbac9b
commit a02ea47681
8 changed files with 22 additions and 19 deletions

View File

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

View File

@ -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)

View File

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

View File

@ -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__)

View File

@ -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,16 +15,17 @@ 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():
# noinspection PyUnusedLocal
class MyAbstractType(AbstractType): class MyAbstractType(AbstractType):
field1 = MyScalar() field1 = MyScalar()
assert abstracttype.warn_deprecation.called
def test_generate_objecttype_inherit_abstracttype(): def test_generate_objecttype_inherit_abstracttype():
with deprecated_call():
class MyAbstractType(AbstractType): class MyAbstractType(AbstractType):
field1 = MyScalar() field1 = MyScalar()

View File

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

View File

@ -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):

View File

@ -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):