From a8d394c39c4e51457e7c15081cff09e21888d8cc Mon Sep 17 00:00:00 2001
From: vtexier <vit@free.fr>
Date: Sat, 10 Nov 2018 10:41:20 +0100
Subject: [PATCH] issue #52 add type hinting to helpers module

---
 duniterpy/helpers.py         | 7 ++++---
 duniterpy/key/signing_key.py | 5 +++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/duniterpy/helpers.py b/duniterpy/helpers.py
index 851b1cbd..5e7f68b0 100644
--- a/duniterpy/helpers.py
+++ b/duniterpy/helpers.py
@@ -1,6 +1,7 @@
+from typing import Union
 
 
-def ensure_bytes(data):
+def ensure_bytes(data: Union[str, bytes]) -> bytes:
     """
     Convert data in bytes if data is a string
 
@@ -13,7 +14,7 @@ def ensure_bytes(data):
     return data
 
 
-def ensure_str(data):
+def ensure_str(data: Union[str, bytes]) -> str:
     """
     Convert data in str if data are bytes
 
@@ -23,4 +24,4 @@ def ensure_str(data):
     if isinstance(data, bytes):
         return str(data, 'utf-8')
 
-    return data
\ No newline at end of file
+    return data
diff --git a/duniterpy/key/signing_key.py b/duniterpy/key/signing_key.py
index ae5b2384..146699e3 100644
--- a/duniterpy/key/signing_key.py
+++ b/duniterpy/key/signing_key.py
@@ -3,7 +3,7 @@ duniter public and private keys
 
 @author: inso
 """
-from typing import Optional
+from typing import Optional, Union
 
 import libnacl.sign
 from pylibscrypt import scrypt
@@ -30,7 +30,8 @@ class ScryptParams:
 
 
 class SigningKey(libnacl.sign.Signer):
-    def __init__(self, salt: str, password: str, scrypt_params: Optional[ScryptParams] = None) -> None:
+    def __init__(self, salt: Union[str, bytes], password: Union[str, bytes],
+                 scrypt_params: Optional[ScryptParams] = None) -> None:
         """
         Init a SigningKey object from credentials
 
-- 
GitLab