Skip to content

Commit

Permalink
chore: replace print statements with debug logging (#7)
Browse files Browse the repository at this point in the history
* chore: replace print statements with debug logging
* chore: relax eth-ape version constraint

Co-authored-by: Juliya Smith <yingthi@live.com>
  • Loading branch information
lost-theory and antazoey authored Nov 8, 2021
1 parent 769857b commit 9a3c0b1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
run: pip install .[lint]

- name: Run MyPy
run: mypy .
run: mypy . --exclude=build

functional:
runs-on: ${{ matrix.os }}
Expand Down
10 changes: 3 additions & 7 deletions ape_hardhat/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from typing import Any, List, Optional

from ape.exceptions import ProviderError
from ape.logging import logger
from ape_http.providers import DEFAULT_SETTINGS, EthereumProvider, NetworkConfig

EPHEMERAL_PORTS_START = 49152
Expand Down Expand Up @@ -96,14 +97,10 @@ def _kill_process(proc):
class HardhatProviderError(ProviderError):
"""An error related to the Hardhat network provider plugin."""

pass


class HardhatSubprocessError(HardhatProviderError):
"""An error related to launching subprocesses to run Hardhat."""

pass


class HardhatNetworkConfig(NetworkConfig):
# --port <INT, default from Hardhat is 8545, but our default is to assign a random port number>
Expand All @@ -124,7 +121,6 @@ def __post_init__(self):
self.npx_bin = shutil.which("npx")

hardhat_config_file = self.network.config_manager.PROJECT_FOLDER / "hardhat.config.js"

if not hardhat_config_file.is_file():
hardhat_config_file.write_text(HARDHAT_CONFIG)

Expand Down Expand Up @@ -193,7 +189,7 @@ def _verify_connection(self) -> bool:
raise HardhatProviderError(f"Unexpected chain ID: {chain_id}")
return True
except Exception as exc:
print("Hardhat connection failed:", exc)
logger.debug("Hardhat connection failed: %r", exc)
return False

def connect(self):
Expand All @@ -213,7 +209,7 @@ def connect(self):
self._start_process()
break
except HardhatSubprocessError as exc:
print("Retrying hardhat subprocess startup:", exc)
logger.info("Retrying hardhat subprocess startup: %r", exc)

# subprocess should be running and receiving network requests at this point
if not (self.process and self.process.poll() is None and self.port):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
url="https://github.com/ApeWorX/ape-hardhat",
include_package_data=True,
install_requires=[
"eth-ape==0.1.0a23",
"eth-ape>=0.1.0a25",
"importlib-metadata ; python_version<'3.8'",
], # NOTE: Add 3rd party libraries here
python_requires=">=3.7,<4",
Expand Down

0 comments on commit 9a3c0b1

Please sign in to comment.