Skip to content
Snippets Groups Projects

#163: Introduce mypy

Merged Moul requested to merge 163_mypy into main
27 files
+ 381
260
Compare changes
  • Side-by-side
  • Inline
Files
27
+ 8
8
@@ -18,7 +18,7 @@ import sys
@@ -18,7 +18,7 @@ import sys
from getpass import getpass
from getpass import getpass
from pathlib import Path
from pathlib import Path
from click import command, confirm, option, pass_context
from click import Context, command, confirm, option, pass_context
from duniterpy.key import SigningKey
from duniterpy.key import SigningKey
from duniterpy.key.scrypt_params import ScryptParams
from duniterpy.key.scrypt_params import ScryptParams
@@ -31,7 +31,7 @@ PUBSEC_SIGNKEY_PATTERN = "sec: ([1-9A-HJ-NP-Za-km-z]{87,90})"
@@ -31,7 +31,7 @@ PUBSEC_SIGNKEY_PATTERN = "sec: ([1-9A-HJ-NP-Za-km-z]{87,90})"
@pass_context
@pass_context
def auth_method(ctx):
def auth_method(ctx: Context) -> SigningKey:
if ctx.obj["AUTH_SEED"]:
if ctx.obj["AUTH_SEED"]:
return auth_by_seed()
return auth_by_seed()
if ctx.obj["AUTH_FILE"]:
if ctx.obj["AUTH_FILE"]:
@@ -43,7 +43,7 @@ def auth_method(ctx):
@@ -43,7 +43,7 @@ def auth_method(ctx):
@pass_context
@pass_context
def has_auth_method(ctx):
def has_auth_method(ctx: Context) -> bool:
return (
return (
ctx.obj["AUTH_SCRYPT"]
ctx.obj["AUTH_SCRYPT"]
or ctx.obj["AUTH_FILE"]
or ctx.obj["AUTH_FILE"]
@@ -54,7 +54,7 @@ def has_auth_method(ctx):
@@ -54,7 +54,7 @@ def has_auth_method(ctx):
@command("authfile", help="Generate authentication file")
@command("authfile", help="Generate authentication file")
@option("--file", default="authfile", show_default=True, help="Path file")
@option("--file", default="authfile", show_default=True, help="Path file")
def generate_auth_file(file):
def generate_auth_file(file: str) -> None:
key = auth_method()
key = auth_method()
authfile = Path(file)
authfile = Path(file)
pubkey_cksum = gen_pubkey_checksum(key.pubkey)
pubkey_cksum = gen_pubkey_checksum(key.pubkey)
@@ -70,7 +70,7 @@ to following pubkey `{pubkey_cksum}`?"
@@ -70,7 +70,7 @@ to following pubkey `{pubkey_cksum}`?"
@pass_context
@pass_context
def auth_by_auth_file(ctx):
def auth_by_auth_file(ctx: Context) -> SigningKey:
"""
"""
Uses an authentication file to generate the key
Uses an authentication file to generate the key
Authfile can either be:
Authfile can either be:
@@ -97,7 +97,7 @@ def auth_by_auth_file(ctx):
@@ -97,7 +97,7 @@ def auth_by_auth_file(ctx):
sys.exit("Error: the format of the file is invalid")
sys.exit("Error: the format of the file is invalid")
def auth_by_seed():
def auth_by_seed() -> SigningKey:
seedhex = getpass("Please enter your seed on hex format: ")
seedhex = getpass("Please enter your seed on hex format: ")
try:
try:
return SigningKey.from_seedhex(seedhex)
return SigningKey.from_seedhex(seedhex)
@@ -106,7 +106,7 @@ def auth_by_seed():
@@ -106,7 +106,7 @@ def auth_by_seed():
@pass_context
@pass_context
def auth_by_scrypt(ctx):
def auth_by_scrypt(ctx: Context) -> SigningKey:
salt = getpass("Please enter your Scrypt Salt (Secret identifier): ")
salt = getpass("Please enter your Scrypt Salt (Secret identifier): ")
password = getpass("Please enter your Scrypt password (masked): ")
password = getpass("Please enter your Scrypt password (masked): ")
@@ -129,7 +129,7 @@ def auth_by_scrypt(ctx):
@@ -129,7 +129,7 @@ def auth_by_scrypt(ctx):
sys.exit(error)
sys.exit(error)
def auth_by_wif():
def auth_by_wif() -> SigningKey:
wif_hex = getpass("Enter your WIF or Encrypted WIF address (masked): ")
wif_hex = getpass("Enter your WIF or Encrypted WIF address (masked): ")
password = getpass(
password = getpass(
"(Leave empty in case WIF format) Enter the Encrypted WIF password (masked): "
"(Leave empty in case WIF format) Enter the Encrypted WIF password (masked): "
Loading