Skip to content
Snippets Groups Projects
Commit 3f79a760 authored by Moul's avatar Moul
Browse files

[mypy] #163: Add type annotation on wot_tools

parent b46ff8e9
No related branches found
No related tags found
1 merge request!214#163: Introduce mypy
...@@ -13,12 +13,14 @@ ...@@ -13,12 +13,14 @@
# You should have received a copy of the GNU Affero General Public License # You should have received a copy of the GNU Affero General Public License
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
from typing import Dict, List, Optional
from duniterpy.api.bma import wot from duniterpy.api.bma import wot
from silkaj.network_tools import client_instance from silkaj.network_tools import client_instance
def identity_of(pubkey_uid): def identity_of(pubkey_uid: str) -> Dict:
""" """
Only works for members Only works for members
Not able to get corresponding uid from a non-member identity Not able to get corresponding uid from a non-member identity
...@@ -31,7 +33,7 @@ def identity_of(pubkey_uid): ...@@ -31,7 +33,7 @@ def identity_of(pubkey_uid):
pass pass
def is_member(pubkey_uid): def is_member(pubkey_uid: str) -> Optional[Dict]:
""" """
Check identity is member Check identity is member
If member, return corresponding identity, else: False If member, return corresponding identity, else: False
...@@ -39,10 +41,10 @@ def is_member(pubkey_uid): ...@@ -39,10 +41,10 @@ def is_member(pubkey_uid):
try: try:
return identity_of(pubkey_uid) return identity_of(pubkey_uid)
except Exception: except Exception:
return False return None
def wot_lookup(identifier): def wot_lookup(identifier: str) -> List:
""" """
:identifier: identity or pubkey in part or whole :identifier: identity or pubkey in part or whole
Return received and sent certifications lists of matching identities Return received and sent certifications lists of matching identities
...@@ -52,7 +54,7 @@ def wot_lookup(identifier): ...@@ -52,7 +54,7 @@ def wot_lookup(identifier):
return (client(wot.lookup, identifier))["results"] 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 Make list of pubkeys unique, and remove empty strings
Request identities Request identities
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment