mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Fixed Python 2/3 issues and flake syntax issues
This commit is contained in:
parent
f8561fa5c4
commit
6c4f4624e3
|
@ -1,4 +1,5 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
import six
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
|
@ -9,3 +10,10 @@ try:
|
||||||
from inspect import signature
|
from inspect import signature
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from .signature import signature
|
from .signature import signature
|
||||||
|
|
||||||
|
if six.PY2:
|
||||||
|
def func_name(func):
|
||||||
|
return func.func_name
|
||||||
|
else:
|
||||||
|
def func_name(func):
|
||||||
|
return func.__name__
|
||||||
|
|
|
@ -3,8 +3,8 @@ import pytest
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..unmountedtype import UnmountedType
|
from ..unmountedtype import UnmountedType
|
||||||
from ..abstracttype import AbstractType
|
from ..abstracttype import AbstractType
|
||||||
|
from .. import abstracttype
|
||||||
from ..field import Field
|
from ..field import Field
|
||||||
from ...utils import deprecated
|
|
||||||
|
|
||||||
|
|
||||||
class MyType(ObjectType):
|
class MyType(ObjectType):
|
||||||
|
@ -18,12 +18,12 @@ class MyScalar(UnmountedType):
|
||||||
|
|
||||||
|
|
||||||
def test_abstract_objecttype_warn_deprecation(mocker):
|
def test_abstract_objecttype_warn_deprecation(mocker):
|
||||||
mocker.patch.object(deprecated, 'warn_deprecation')
|
mocker.patch.object(abstracttype, 'warn_deprecation')
|
||||||
|
|
||||||
class MyAbstractType(AbstractType):
|
class MyAbstractType(AbstractType):
|
||||||
field1 = MyScalar()
|
field1 = MyScalar()
|
||||||
|
|
||||||
deprecated.warn_deprecation.assert_called_once()
|
abstracttype.warn_deprecation.assert_called_once()
|
||||||
|
|
||||||
|
|
||||||
def test_generate_objecttype_inherit_abstracttype():
|
def test_generate_objecttype_inherit_abstracttype():
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import six
|
import six
|
||||||
from functools import wraps
|
from ..pyutils.compat import signature, func_name
|
||||||
from ..pyutils.compat import signature
|
|
||||||
|
|
||||||
from .deprecated import warn_deprecation
|
from .deprecated import warn_deprecation
|
||||||
|
|
||||||
|
@ -25,7 +24,7 @@ def annotate(_func=None, _trigger_warning=True, **annotations):
|
||||||
'The key {key} is not a function parameter in the function "{func_name}".'
|
'The key {key} is not a function parameter in the function "{func_name}".'
|
||||||
).format(
|
).format(
|
||||||
key=key,
|
key=key,
|
||||||
func_name=_func.func_name
|
func_name=func_name(_func)
|
||||||
)
|
)
|
||||||
|
|
||||||
func_annotations = getattr(_func, '__annotations__', None)
|
func_annotations = getattr(_func, '__annotations__', None)
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from six import PY2
|
from six import PY2
|
||||||
from functools import wraps
|
|
||||||
from .annotate import annotate
|
from .annotate import annotate
|
||||||
from .deprecated import deprecated
|
from .deprecated import deprecated
|
||||||
|
|
||||||
|
@ -11,9 +10,11 @@ if PY2:
|
||||||
else:
|
else:
|
||||||
deprecation_reason = (
|
deprecation_reason = (
|
||||||
'The decorator @resolve_only_args is deprecated.\n'
|
'The decorator @resolve_only_args is deprecated.\n'
|
||||||
'Please use Python 3 type annotations instead. Read more: https://docs.python.org/3/library/typing.html'
|
'Please use Python 3 type annotations instead. Read more: '
|
||||||
|
'https://docs.python.org/3/library/typing.html'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@deprecated(deprecation_reason)
|
@deprecated(deprecation_reason)
|
||||||
def resolve_only_args(func):
|
def resolve_only_args(func):
|
||||||
return annotate(func)
|
return annotate(func)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user