From 3f79a7603b4acae3638fffef01d25488591dbd8d Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sun, 5 Jun 2022 16:43:03 +0200 Subject: [PATCH] [mypy] #163: Add type annotation on wot_tools --- silkaj/wot_tools.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/silkaj/wot_tools.py b/silkaj/wot_tools.py index 13281dee..f92c81b5 100644 --- a/silkaj/wot_tools.py +++ b/silkaj/wot_tools.py @@ -13,12 +13,14 @@ # You should have received a copy of the GNU Affero General Public License # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. +from typing import Dict, List, Optional + from duniterpy.api.bma import wot from silkaj.network_tools import client_instance -def identity_of(pubkey_uid): +def identity_of(pubkey_uid: str) -> Dict: """ Only works for members Not able to get corresponding uid from a non-member identity @@ -31,7 +33,7 @@ def identity_of(pubkey_uid): pass -def is_member(pubkey_uid): +def is_member(pubkey_uid: str) -> Optional[Dict]: """ Check identity is member If member, return corresponding identity, else: False @@ -39,10 +41,10 @@ def is_member(pubkey_uid): try: return identity_of(pubkey_uid) except Exception: - return False + return None -def wot_lookup(identifier): +def wot_lookup(identifier: str) -> List: """ :identifier: identity or pubkey in part or whole Return received and sent certifications lists of matching identities @@ -52,7 +54,7 @@ def wot_lookup(identifier): return (client(wot.lookup, identifier))["results"] -def identities_from_pubkeys(pubkeys, uids): +def identities_from_pubkeys(pubkeys: List[str], uids: bool) -> List: """ Make list of pubkeys unique, and remove empty strings Request identities -- GitLab