Skip to content

Commit

Permalink
style: fix typing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matejcik authored and andrewkozlik committed May 14, 2024
1 parent e0d23bd commit 8890b63
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions shamir_mnemonic/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def print_group_status(idx: int) -> None:

def print_status() -> None:
bn = style(str(recovery_state.groups_complete()), bold=True)
assert recovery_state.parameters is not None
bt = style(str(recovery_state.parameters.group_threshold), bold=True)
click.echo()
if recovery_state.parameters.group_count > 1:
Expand Down
2 changes: 2 additions & 0 deletions shamir_mnemonic/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ def recover(self, passphrase: bytes) -> bytes:
if group.is_complete():
reduced_groups[group_index] = group.get_minimal_group()

# some groups have been added so parameters must be known
assert self.parameters is not None
if len(reduced_groups) >= self.parameters.group_threshold:
break

Expand Down
8 changes: 4 additions & 4 deletions shamir_mnemonic/shamir.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import hmac
import secrets
from typing import Any, Dict, Iterable, List, NamedTuple, Sequence, Set, Tuple
from typing import Any, Dict, Iterable, Iterator, List, NamedTuple, Sequence, Set, Tuple

import attr

Expand Down Expand Up @@ -49,7 +49,7 @@ class ShareGroup:
def __init__(self) -> None:
self.shares: Set[Share] = set()

def __iter__(self) -> Iterable[Share]:
def __iter__(self) -> Iterator[Share]:
return iter(self.shares)

def __len__(self) -> int:
Expand Down Expand Up @@ -94,7 +94,7 @@ def group_parameters(self) -> ShareGroupParameters:
def member_threshold(self) -> int:
return next(iter(self.shares)).member_threshold

def is_complete(self) -> int:
def is_complete(self) -> bool:
if self.shares:
return len(self.shares) >= self.member_threshold()
else:
Expand Down Expand Up @@ -295,7 +295,7 @@ def split_ems(
group_threshold: int,
groups: Sequence[Tuple[int, int]],
encrypted_master_secret: EncryptedMasterSecret,
) -> List[List[str]]:
) -> List[List[Share]]:
"""
Split an Encrypted Master Secret into mnemonic shares.
Expand Down

0 comments on commit 8890b63

Please sign in to comment.