From 02131a6ee05fd06dc6acaa6df4a393fabbec0277 Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Tue, 18 May 2021 17:33:38 -0500 Subject: [PATCH] Fix Sphinx warning - Cannot resolve forward reference in type annotations of "ipfshttpclient.Client.config.set": name 'json_list_t' is not defined --- ipfshttpclient/utils.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ipfshttpclient/utils.py b/ipfshttpclient/utils.py index 0e98cdca..8433a83f 100644 --- a/ipfshttpclient/utils.py +++ b/ipfshttpclient/utils.py @@ -51,21 +51,25 @@ def __fspath__(self) -> ty.AnyStr: # work around GH/mypy/mypy#731: no recursive structural types yet json_primitive_t = ty.Union[bool, float, int, str] -json_value_t = ty.Union[ - json_primitive_t, - "json_list_t", - "json_dict_t" -] -class json_list_t(ty.List[json_value_t]): +# noinspection PyPep8Naming +class json_list_t(ty.List["json_value_t"]): pass -class json_dict_t(ty.Dict[str, json_value_t]): +# noinspection PyPep8Naming +class json_dict_t(ty.Dict[str, "json_value_t"]): pass +json_value_t = ty.Union[ + json_primitive_t, + json_list_t, + json_dict_t +] + + def maybe_fsencode(val: str, ref: ty.AnyStr) -> ty.AnyStr: """Encodes the string *val* using the system filesystem encoding if *ref* is of type :type:`bytes`"""