Skip to content

Commit

Permalink
Fix Sphinx warning - Cannot resolve forward reference in type annotat…
Browse files Browse the repository at this point in the history
…ions of "ipfshttpclient.Client.config.set": name 'json_list_t' is not defined
  • Loading branch information
c0llab0rat0r authored and ntninja committed May 30, 2021
1 parent c03867a commit 02131a6
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions ipfshttpclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`"""
Expand Down

0 comments on commit 02131a6

Please sign in to comment.