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
|
||||
from collections import Iterable
|
||||
from collections.abc import Iterable
|
||||
from functools import partial
|
||||
|
||||
from graphql_relay import connection_from_array
|
||||
|
|
|
@ -21,7 +21,7 @@ class CreatePostResult(graphene.Union):
|
|||
|
||||
|
||||
class CreatePost(graphene.Mutation):
|
||||
class Input:
|
||||
class Arguments:
|
||||
text = graphene.String(required=True)
|
||||
|
||||
result = graphene.Field(CreatePostResult)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import inspect
|
||||
from collections import Mapping, OrderedDict
|
||||
from collections.abc import Mapping
|
||||
from functools import partial
|
||||
|
||||
from .argument import Argument, to_arguments
|
||||
|
@ -59,7 +59,7 @@ class Field(MountedType):
|
|||
|
||||
self.name = name
|
||||
self._type = type
|
||||
self.args = to_arguments(args or OrderedDict(), extra_args)
|
||||
self.args = to_arguments(args or {}, extra_args)
|
||||
if source:
|
||||
resolver = partial(source_resolver, source)
|
||||
self.resolver = resolver
|
||||
|
|
|
@ -47,7 +47,7 @@ class Mutation(ObjectType):
|
|||
warn_deprecation(
|
||||
(
|
||||
"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:"
|
||||
" https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#mutation-input"
|
||||
).format(name=cls.__name__)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from .. import abstracttype
|
||||
from pytest import deprecated_call
|
||||
|
||||
from ..abstracttype import AbstractType
|
||||
from ..field import Field
|
||||
from ..objecttype import ObjectType
|
||||
|
@ -14,21 +15,22 @@ class MyScalar(UnmountedType):
|
|||
return MyType
|
||||
|
||||
|
||||
def test_abstract_objecttype_warn_deprecation(mocker):
|
||||
mocker.patch.object(abstracttype, "warn_deprecation")
|
||||
def test_abstract_objecttype_warn_deprecation():
|
||||
with deprecated_call():
|
||||
|
||||
class MyAbstractType(AbstractType):
|
||||
field1 = MyScalar()
|
||||
|
||||
assert abstracttype.warn_deprecation.called
|
||||
# noinspection PyUnusedLocal
|
||||
class MyAbstractType(AbstractType):
|
||||
field1 = MyScalar()
|
||||
|
||||
|
||||
def test_generate_objecttype_inherit_abstracttype():
|
||||
class MyAbstractType(AbstractType):
|
||||
field1 = MyScalar()
|
||||
with deprecated_call():
|
||||
|
||||
class MyObjectType(ObjectType, MyAbstractType):
|
||||
field2 = MyScalar()
|
||||
class MyAbstractType(AbstractType):
|
||||
field1 = MyScalar()
|
||||
|
||||
class MyObjectType(ObjectType, MyAbstractType):
|
||||
field2 = MyScalar()
|
||||
|
||||
assert MyObjectType._meta.description is None
|
||||
assert MyObjectType._meta.interfaces == ()
|
||||
|
|
|
@ -182,9 +182,10 @@ def test_bad_variables(sample_date, sample_datetime, sample_time):
|
|||
),
|
||||
variables={"input": input_},
|
||||
)
|
||||
assert result.errors and len(result.errors) == 1
|
||||
# when `input` is not JSON serializable formatting the error message in
|
||||
# `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 result.data is None
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import json
|
||||
from collections import Mapping
|
||||
from collections.abc import Mapping
|
||||
|
||||
|
||||
def to_key(value):
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from collections import Mapping
|
||||
from collections.abc import Mapping
|
||||
|
||||
|
||||
def deflate(node, index=None, path=None):
|
||||
|
|
Loading…
Reference in New Issue
Block a user