Skip to content

Commit 1a2261d

Browse files
committed
Clean up, add analyze target
1 parent 2a5a47a commit 1a2261d

File tree

15 files changed

+54
-63
lines changed

15 files changed

+54
-63
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
include LICENSE
22
include README.md
33
include requirements.txt
4-
include requirements/slip39.txt
54
include requirements/cli.txt
65
include requirements/tests.txt
76
include requirements/docs.txt

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export NIX_OPTS ?=
3131
help:
3232
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3333

34-
.PHONY: help wheel install venv Makefile FORCE
34+
.PHONY: help wheel install test analyze venv Makefile FORCE
3535

3636

3737
wheel: $(WHEEL)
@@ -55,6 +55,11 @@ unit-%:
5555
test:
5656
$(PYTEST) $(PYTEST_OPTS) tests
5757

58+
analyze:
59+
$(PYTHON) -m flake8 --color never -j 1 --max-line-length=250 \
60+
--ignore=W503,W504,E201,E202,E223,E226 \
61+
hdwallet
62+
5863
#
5964
# Nix and VirtualEnv build, install and activate
6065
#

hdwallet/cli/generate/seed.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def generate_seed(**kwargs) -> None:
3030
if not MNEMONICS.mnemonic(name="Electrum-V2").is_valid(
3131
mnemonic=kwargs.get("mnemonic"), mnemonic_type=kwargs.get("mnemonic_type")
3232
):
33-
click.echo(click.style(f"Invalid Electrum-V2 mnemonic"), err=True)
33+
click.echo(click.style("Invalid Electrum-V2 mnemonic"), err=True)
3434
sys.exit()
3535
elif kwargs.get("client") != SLIP39Seed.name(): # SLIP39 supports any 128-, 256- or 512-bit Mnemonic
3636
mnemonic_name: str = "BIP39" if kwargs.get("client") == CardanoSeed.name() else kwargs.get("client")
3737
if not MNEMONICS.mnemonic(name=mnemonic_name).is_valid(mnemonic=kwargs.get("mnemonic")):
38-
click.echo(click.style(f"Invalid {mnemonic_name} mnemonic {kwargs.get('mnemonic')!r}"), err=True)
38+
click.echo(click.style(f"Invalid {mnemonic_name} mnemonic"), err=True)
3939
sys.exit()
4040

4141
if kwargs.get("client") == BIP39Seed.name():

hdwallet/entropies/ientropy.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020
class IEntropy:
21-
21+
2222
_entropy: str
2323
_strength: int
2424

@@ -148,4 +148,4 @@ def are_entropy_bits_enough(self, entropy: Union[bytes, int]) -> bool:
148148
"""
149149

150150
if self.name() != "Electrum-V2":
151-
raise NotImplemented
151+
raise NotImplementedError

hdwallet/mnemonics/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
)
1010

1111
from ..exceptions import MnemonicError
12-
from .algorand import (
12+
from .algorand import ( # noqa: F401
1313
AlgorandMnemonic, ALGORAND_MNEMONIC_WORDS, ALGORAND_MNEMONIC_LANGUAGES
1414
)
15-
from .bip39 import (
15+
from .bip39 import ( # noqa: F401
1616
BIP39Mnemonic, BIP39_MNEMONIC_WORDS, BIP39_MNEMONIC_LANGUAGES
1717
)
18-
from .slip39 import (
18+
from .slip39 import ( # noqa: F401
1919
SLIP39Mnemonic, SLIP39_MNEMONIC_WORDS, SLIP39_MNEMONIC_LANGUAGES
2020
)
21-
from .electrum import (
21+
from .electrum import ( # noqa: F401
2222
ElectrumV1Mnemonic, ELECTRUM_V1_MNEMONIC_WORDS, ELECTRUM_V1_MNEMONIC_LANGUAGES,
2323
ElectrumV2Mnemonic, ELECTRUM_V2_MNEMONIC_WORDS, ELECTRUM_V2_MNEMONIC_LANGUAGES, ELECTRUM_V2_MNEMONIC_TYPES
2424
)
25-
from .monero import (
25+
from .monero import ( # noqa: F401
2626
MoneroMnemonic, MONERO_MNEMONIC_WORDS, MONERO_MNEMONIC_LANGUAGES
2727
)
2828
from .imnemonic import IMnemonic
@@ -44,6 +44,8 @@ class MNEMONICS:
4444
+--------------+------------------------------------------------------------------------+
4545
| BIP39 | :class:`hdwallet.mnemonics.bip39.mnemonic.BIP39Mnemonic` |
4646
+--------------+------------------------------------------------------------------------+
47+
| SLIP39 | :class:`hdwallet.mnemonics.slip39.mnemonic.SLIP39Mnemonic` |
48+
+--------------+------------------------------------------------------------------------+
4749
| Electrum-V1 | :class:`hdwallet.mnemonics.electrum.v1.mnemonic.ElectrumV1Mnemonic` |
4850
+--------------+------------------------------------------------------------------------+
4951
| Electrum-V2 | :class:`hdwallet.mnemonics.electrum.v2.mnemonic.ElectrumV2Mnemonic` |
@@ -55,10 +57,10 @@ class MNEMONICS:
5557
dictionary: Dict[str, Type[IMnemonic]] = {
5658
AlgorandMnemonic.name(): AlgorandMnemonic,
5759
BIP39Mnemonic.name(): BIP39Mnemonic,
60+
SLIP39Mnemonic.name(): SLIP39Mnemonic,
5861
ElectrumV1Mnemonic.name(): ElectrumV1Mnemonic,
5962
ElectrumV2Mnemonic.name(): ElectrumV2Mnemonic,
6063
MoneroMnemonic.name(): MoneroMnemonic,
61-
SLIP39Mnemonic.name(): SLIP39Mnemonic,
6264
}
6365

6466
@classmethod

hdwallet/mnemonics/algorand/mnemonic.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
Union, Dict, List, Optional
99
)
1010

11-
import unicodedata
12-
1311
from ...entropies import (
1412
IEntropy, AlgorandEntropy, ALGORAND_ENTROPY_STRENGTHS
1513
)
1614
from ...crypto import sha512_256
1715
from ...exceptions import (
18-
Error, EntropyError, MnemonicError, ChecksumError
16+
EntropyError, MnemonicError, ChecksumError
1917
)
2018
from ...utils import (
2119
get_bytes, bytes_to_string, convert_bits

hdwallet/mnemonics/electrum/v1/mnemonic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
Dict, List, Union, Optional
99
)
1010

11-
import unicodedata
12-
1311
from ....entropies import (
1412
IEntropy, ElectrumV1Entropy, ELECTRUM_V1_ENTROPY_STRENGTHS
1513
)

hdwallet/mnemonics/electrum/v2/mnemonic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
Dict, List, Union, Optional
99
)
1010

11-
import unicodedata
12-
1311
from ....entropies import (
1412
IEntropy, ElectrumV2Entropy, ELECTRUM_V2_ENTROPY_STRENGTHS
1513
)

hdwallet/mnemonics/imnemonic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def mnemonic_type(self) -> str:
7272
:rtype: str
7373
"""
7474

75-
raise NotImplemented
75+
raise NotImplementedError
7676

7777
def language(self) -> str:
7878
"""
@@ -245,6 +245,6 @@ def normalize(cls, mnemonic: Union[str, List[str]]) -> List[str]:
245245
if isinstance(mnemonic, str):
246246
if ( len(mnemonic.strip()) * 4 in cls.words_to_entropy_strength.values()
247247
and all(c in string.hexdigits for c in mnemonic.strip())):
248-
mnemonic: str = cls.from_entropy(mnemonic, language="english")
248+
mnemonic: str = cls.from_entropy(mnemonic, language="english")
249249
mnemonic: list = mnemonic.strip().split()
250250
return list(map(lambda _: unicodedata.normalize("NFKD", _.lower()), mnemonic))

hdwallet/mnemonics/monero/mnemonic.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
Union, Dict, List
99
)
1010

11-
import unicodedata
12-
1311
from ...entropies import (
1412
IEntropy, MoneroEntropy, MONERO_ENTROPY_STRENGTHS
1513
)

0 commit comments

Comments
 (0)