Skip to content
Snippets Groups Projects
Commit a8d394c3 authored by Vincent Texier's avatar Vincent Texier
Browse files

issue #52 add type hinting to helpers module

parent 90b0501c
No related branches found
No related tags found
No related merge requests found
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 Convert data in bytes if data is a string
...@@ -13,7 +14,7 @@ def ensure_bytes(data): ...@@ -13,7 +14,7 @@ def ensure_bytes(data):
return data return data
def ensure_str(data): def ensure_str(data: Union[str, bytes]) -> str:
""" """
Convert data in str if data are bytes Convert data in str if data are bytes
......
...@@ -3,7 +3,7 @@ duniter public and private keys ...@@ -3,7 +3,7 @@ duniter public and private keys
@author: inso @author: inso
""" """
from typing import Optional from typing import Optional, Union
import libnacl.sign import libnacl.sign
from pylibscrypt import scrypt from pylibscrypt import scrypt
...@@ -30,7 +30,8 @@ class ScryptParams: ...@@ -30,7 +30,8 @@ class ScryptParams:
class SigningKey(libnacl.sign.Signer): 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 Init a SigningKey object from credentials
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment