Commit a8d394c3 authored by Vincent Texier's avatar Vincent Texier

issue #52 add type hinting to helpers module

parent 90b0501c
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
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment