From 2d65a91aac4d7e7e2745550492c8d11d52f68e19 Mon Sep 17 00:00:00 2001 From: Eran Kampf Date: Sat, 1 Jun 2019 14:51:25 -0700 Subject: [PATCH] File is deprecated and not used anywhere --- graphene/utils/annotate.py | 35 ------------------------- graphene/utils/tests/test_annotate.py | 37 --------------------------- 2 files changed, 72 deletions(-) delete mode 100644 graphene/utils/annotate.py delete mode 100644 graphene/utils/tests/test_annotate.py diff --git a/graphene/utils/annotate.py b/graphene/utils/annotate.py deleted file mode 100644 index 43a26ef6..00000000 --- a/graphene/utils/annotate.py +++ /dev/null @@ -1,35 +0,0 @@ -import six - -from ..pyutils.compat import func_name, signature -from .deprecated import warn_deprecation - - -def annotate(_func=None, _trigger_warning=True, **annotations): - if not six.PY2 and _trigger_warning: - warn_deprecation( - "annotate is intended for use in Python 2 only, as you can use type annotations Python 3.\n" - "Read more in https://docs.python.org/3/library/typing.html" - ) - - if not _func: - - def _func(f): - return annotate(f, **annotations) - - return _func - - func_signature = signature(_func) - - # We make sure the annotations are valid - for key, value in annotations.items(): - assert key in func_signature.parameters, ( - 'The key {key} is not a function parameter in the function "{func_name}".' - ).format(key=key, func_name=func_name(_func)) - - func_annotations = getattr(_func, "__annotations__", None) - if func_annotations is None: - _func.__annotations__ = annotations - else: - _func.__annotations__.update(annotations) - - return _func diff --git a/graphene/utils/tests/test_annotate.py b/graphene/utils/tests/test_annotate.py deleted file mode 100644 index 1b7b4ce1..00000000 --- a/graphene/utils/tests/test_annotate.py +++ /dev/null @@ -1,37 +0,0 @@ -import pytest - -from ..annotate import annotate - - -def func(a, b, *c, **d): - pass - - -annotations = {"a": int, "b": str, "c": list, "d": dict} - - -def func_with_annotations(a, b, *c, **d): - pass - - -func_with_annotations.__annotations__ = annotations - - -def test_annotate_with_no_params(): - annotated_func = annotate(func, _trigger_warning=False) - assert annotated_func.__annotations__ == {} - - -def test_annotate_with_params(): - annotated_func = annotate(_trigger_warning=False, **annotations)(func) - assert annotated_func.__annotations__ == annotations - - -def test_annotate_with_wront_params(): - with pytest.raises(Exception) as exc_info: - annotate(p=int, _trigger_warning=False)(func) - - assert ( - str(exc_info.value) - == 'The key p is not a function parameter in the function "func".' - )