Skip to content

Commit

Permalink
Use ValidationError from eth_utils
Browse files Browse the repository at this point in the history
Having a ValidationError defined both here and there makes no sense
and forces callsites to catch them both in some situations.
  • Loading branch information
gsalgado committed Mar 10, 2020
1 parent a181917 commit 00e27eb
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
3 changes: 2 additions & 1 deletion eth_keys/datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
keccak,
to_checksum_address,
to_normalized_address,
ValidationError,

)

from eth_keys.utils.address import (
Expand All @@ -41,7 +43,6 @@

from eth_keys.exceptions import (
BadSignature,
ValidationError,
)
from eth_keys.validation import (
validate_private_key_bytes,
Expand Down
4 changes: 0 additions & 4 deletions eth_keys/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
class ValidationError(Exception):
pass


class BadSignature(Exception):
pass
8 changes: 5 additions & 3 deletions eth_keys/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
from typing import (Any, Union, Type) # noqa: F401

from eth_utils import (
is_string,
ValidationError,
)

from eth_keys.datatypes import (
BaseSignature,
LazyBackend,
Expand All @@ -8,9 +13,6 @@
PrivateKey,
Signature,
)
from eth_keys.exceptions import (
ValidationError,
)
from eth_keys.validation import (
validate_message_hash,
validate_compressed_public_key_bytes,
Expand Down
4 changes: 1 addition & 3 deletions eth_keys/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
encode_hex,
is_bytes,
is_integer,
ValidationError,
)
from eth_utils.toolz import curry

from eth_keys.constants import (
SECPK1_N,
)
from eth_keys.exceptions import (
ValidationError,
)


def validate_integer(value: Any) -> None:
Expand Down
4 changes: 1 addition & 3 deletions tests/core/test_key_and_signature_datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
is_normalized_address,
is_checksum_address,
is_canonical_address,
ValidationError,
)

from eth_keys import KeyAPI
from eth_keys.backends import NativeECCBackend
from eth_keys.exceptions import (
ValidationError,
)


MSG = b'message'
Expand Down
2 changes: 1 addition & 1 deletion tests/core/test_key_api_proxy_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

from eth_utils import (
keccak,
ValidationError,
)

from eth_keys import KeyAPI
from eth_keys.backends import NativeECCBackend
from eth_keys.exceptions import ValidationError


MSG = b'message'
Expand Down

0 comments on commit 00e27eb

Please sign in to comment.