Skip to content

Commit 3e77455

Browse files
committed
Move PyEthPMException -> EthPMException
1 parent b7ef938 commit 3e77455

File tree

6 files changed

+30
-30
lines changed

6 files changed

+30
-30
lines changed

ethpm/exceptions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
class PyEthPMException(Exception):
1+
class EthPMException(Exception):
22
"""
33
Base class for all Py-EthPM errors.
44
"""
55

66
pass
77

88

9-
class InsufficientAssetsError(PyEthPMException):
9+
class InsufficientAssetsError(EthPMException):
1010
"""
1111
Raised when a Manifest or Package does not contain the required
1212
assets to do something.
@@ -15,47 +15,47 @@ class InsufficientAssetsError(PyEthPMException):
1515
pass
1616

1717

18-
class EthPMValidationError(PyEthPMException):
18+
class EthPMValidationError(EthPMException):
1919
"""
2020
Raised when something does not pass a validation check.
2121
"""
2222

2323
pass
2424

2525

26-
class CannotHandleURI(PyEthPMException):
26+
class CannotHandleURI(EthPMException):
2727
"""
2828
Raised when the given URI cannot be served by any of the available backends.
2929
"""
3030

3131
pass
3232

3333

34-
class FailureToFetchIPFSAssetsError(PyEthPMException):
34+
class FailureToFetchIPFSAssetsError(EthPMException):
3535
"""
3636
Raised when an attempt to fetch a Package's assets via IPFS failed.
3737
"""
3838

3939
pass
4040

4141

42-
class BytecodeLinkingError(PyEthPMException):
42+
class BytecodeLinkingError(EthPMException):
4343
"""
4444
Raised when an attempt to link a contract factory's bytecode failed.
4545
"""
4646

4747
pass
4848

4949

50-
class ManifestBuildingError(PyEthPMException):
50+
class ManifestBuildingError(EthPMException):
5151
"""
5252
Raised when an attempt to build a manifest failed.
5353
"""
5454

5555
pass
5656

5757

58-
class ManifestValidationError(PyEthPMException):
58+
class ManifestValidationError(EthPMException):
5959
"""
6060
Raised when a provided manifest cannot be published, since it's invalid.
6161
"""

ethpm/package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
)
5454
from ethpm.exceptions import (
5555
BytecodeLinkingError,
56+
EthPMException,
5657
EthPMValidationError,
5758
FailureToFetchIPFSAssetsError,
5859
InsufficientAssetsError,
59-
PyEthPMException,
6060
)
6161
from ethpm.uri import (
6262
resolve_uri_contents,
@@ -338,7 +338,7 @@ def build_dependencies(self) -> "Dependencies":
338338
try:
339339
validate_build_dependency(name, uri)
340340
dependency_package = Package.from_uri(uri, self.w3)
341-
except PyEthPMException as e:
341+
except EthPMException as e:
342342
raise FailureToFetchIPFSAssetsError(
343343
f"Failed to retrieve build dependency: {name} from URI: {uri}.\n"
344344
f"Got error: {e}."

newsfragments/1478.breaking.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
All exceptions inherit from a custom class. EthPM exceptions inherit from PyEthPMException, ENS exceptions inherit from ENSException, and all other web3.py exceptions inherit from Web3Exception
1+
All exceptions inherit from a custom class. EthPM exceptions inherit from EthPMException, ENS exceptions inherit from ENSException, and all other web3.py exceptions inherit from Web3Exception

tests/core/pm-module/test_pm_init.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
Package,
66
)
77
from ethpm.exceptions import (
8+
EthPMException,
89
InsufficientAssetsError,
9-
PyEthPMException,
1010
)
1111
from ethpm.tools import (
1212
get_ethpm_local_manifest,
@@ -121,10 +121,10 @@ def test_get_local_package(w3, tmp_ethpmdir):
121121
def test_get_local_package_with_invalid_ethpmdir(w3, tmp_path):
122122
invalid_ethpmdir = tmp_path / "invalid"
123123
invalid_ethpmdir.mkdir()
124-
with pytest.raises(PyEthPMException, match="not a valid ethPM packages directory."):
124+
with pytest.raises(EthPMException, match="not a valid ethPM packages directory."):
125125
w3.pm.get_local_package("owned", invalid_ethpmdir)
126126

127127

128128
def test_get_local_package_with_uninstalled_package(w3, tmp_ethpmdir):
129-
with pytest.raises(PyEthPMException, match="Package: safe-math not found in "):
129+
with pytest.raises(EthPMException, match="Package: safe-math not found in "):
130130
w3.pm.get_local_package("safe-math", tmp_ethpmdir)

tests/core/pm-module/test_registry_integration.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
LinkableContract,
1313
)
1414
from ethpm.exceptions import (
15-
PyEthPMException,
15+
EthPMException,
1616
)
1717
from web3 import Web3
1818
from web3.pm import (
@@ -60,25 +60,25 @@ def test_pm_set_custom_registry(empty_sol_registry, fresh_w3):
6060

6161
@pytest.mark.xfail(reason="Need to properly add authorization as of 8/10/2022")
6262
def test_pm_must_set_registry_before_all_registry_interaction_functions(fresh_w3):
63-
with pytest.raises(PyEthPMException):
63+
with pytest.raises(EthPMException):
6464
fresh_w3.pm.release_package(
6565
"package", "1.0.0", "ipfs://QmcxvhkJJVpbxEAa6cgW3B6XwPJb79w9GpNUv2P2THUzZR"
6666
)
67-
with pytest.raises(PyEthPMException):
67+
with pytest.raises(EthPMException):
6868
fresh_w3.pm.get_release_id_data(b"invalid_release_id")
69-
with pytest.raises(PyEthPMException):
69+
with pytest.raises(EthPMException):
7070
fresh_w3.pm.get_release_id("package", "1.0.0")
71-
with pytest.raises(PyEthPMException):
71+
with pytest.raises(EthPMException):
7272
fresh_w3.pm.get_release_data("package", "1.0.0")
73-
with pytest.raises(PyEthPMException):
73+
with pytest.raises(EthPMException):
7474
fresh_w3.pm.get_package("package", "1.0.0")
75-
with pytest.raises(PyEthPMException):
75+
with pytest.raises(EthPMException):
7676
fresh_w3.pm.get_all_package_names()
77-
with pytest.raises(PyEthPMException):
77+
with pytest.raises(EthPMException):
7878
fresh_w3.pm.get_all_package_releases("package")
79-
with pytest.raises(PyEthPMException):
79+
with pytest.raises(EthPMException):
8080
fresh_w3.pm.get_release_count("package")
81-
with pytest.raises(PyEthPMException):
81+
with pytest.raises(EthPMException):
8282
fresh_w3.pm.get_package_count()
8383

8484

web3/pm.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
Package,
4040
)
4141
from ethpm.exceptions import (
42+
EthPMException,
4243
ManifestValidationError,
43-
PyEthPMException,
4444
)
4545
from ethpm.uri import (
4646
is_supported_content_addressed_uri,
@@ -362,13 +362,13 @@ def get_local_package(self, package_name: str, ethpm_dir: Path = None) -> Packag
362362
ethpm_dir = Path.cwd() / "_ethpm_packages"
363363

364364
if not ethpm_dir.name == "_ethpm_packages" or not ethpm_dir.is_dir():
365-
raise PyEthPMException(
365+
raise EthPMException(
366366
f"{ethpm_dir} is not a valid ethPM packages directory."
367367
)
368368

369369
local_packages = [pkg.name for pkg in ethpm_dir.iterdir() if pkg.is_dir()]
370370
if package_name not in local_packages:
371-
raise PyEthPMException(
371+
raise EthPMException(
372372
f"Package: {package_name} not found in {ethpm_dir}. "
373373
f"Available packages include: {local_packages}."
374374
)
@@ -406,7 +406,7 @@ def set_registry(self, address: Union[Address, ChecksumAddress, ENS]) -> None:
406406
)
407407
self.registry = SimpleRegistry(addr_lookup, self.w3)
408408
else:
409-
raise PyEthPMException(
409+
raise EthPMException(
410410
"Expected a canonical/checksummed address or ENS name for the address, "
411411
f"instead received {type(address)}."
412412
)
@@ -559,14 +559,14 @@ def _validate_set_registry(self) -> None:
559559
try:
560560
self.registry
561561
except AttributeError:
562-
raise PyEthPMException(
562+
raise EthPMException(
563563
"web3.pm does not have a set registry. "
564564
"Please set registry with either: "
565565
"web3.pm.set_registry(address) or "
566566
"web3.pm.deploy_and_set_registry()"
567567
)
568568
if not isinstance(self.registry, ERC1319Registry):
569-
raise PyEthPMException(
569+
raise EthPMException(
570570
"web3.pm requires an instance of a subclass of ERC1319Registry "
571571
"to be set as the web3.pm.registry attribute. Instead found: "
572572
f"{type(self.registry)}."

0 commit comments

Comments
 (0)