diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3fadb576..33cc57fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,8 +9,7 @@ repos: types: [python] args: [--no-cache] require_serial: true - additional_dependencies: [] - minimum_pre_commit_version: "0" + exclude: ^src/.*core/_vendor/ - id: ruff name: ruff description: "Run 'ruff' for extremely fast Python linting" @@ -19,9 +18,8 @@ repos: "types": [python] args: [--fix, --no-cache] require_serial: false - additional_dependencies: [] - minimum_pre_commit_version: "0" files: "^(src|tests)/" + exclude: ^src/.*core/_vendor/ - id: mypy name: mypy description: "`mypy` will check Python types for correctness" @@ -29,6 +27,5 @@ repos: language: system types_or: [python, pyi] require_serial: true - additional_dependencies: [] - minimum_pre_commit_version: "2.9.2" files: "^(src|tests)/" + exclude: ^src/.*core/_vendor/ diff --git a/pyproject.toml b/pyproject.toml index d52a89ff..7762d4b0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -140,7 +140,7 @@ exclude = [ "node_modules", "venv", "docs/sphinx", - "src/algokit/core/_vendor/*", + "src/**/core/_vendor", ] # Allow unused variables when underscore-prefixed. lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" @@ -163,7 +163,7 @@ markers = [ addopts = "-m 'not pyinstaller_binary_tests'" # by default, exclude pyinstaller_binary_tests [tool.mypy] files = ["src", "tests"] -exclude = ["dist", "src/algokit/core/_vendor/*"] +exclude = ["dist", "*/_vendor/*"] python_version = "3.10" warn_unused_ignores = true warn_redundant_casts = true diff --git a/src/algokit/cli/localnet.py b/src/algokit/cli/localnet.py index 07ce0267..30417289 100644 --- a/src/algokit/cli/localnet.py +++ b/src/algokit/cli/localnet.py @@ -9,6 +9,7 @@ from algokit.cli.explore import explore_command from algokit.cli.goal import goal_command from algokit.core import proc +from algokit.core.conf import get_app_config_dir from algokit.core.config_commands.container_engine import get_container_engine, save_container_engine from algokit.core.sandbox import ( COMPOSE_VERSION_COMMAND, @@ -126,7 +127,7 @@ def config_command(*, engine: str | None, force: bool) -> None: default=None, help="Specify a name for a custom LocalNet instance. " "AlgoKit will not manage the configuration of named LocalNet instances, " - "allowing developers to configure it in any way they need.", + f"allowing developers to configure it in any way they need. Defaults to '{SANDBOX_BASE_NAME}'.", ) @click.option( "--config-dir", @@ -135,7 +136,7 @@ def config_command(*, engine: str | None, force: bool) -> None: type=click.Path(exists=True, readable=True, file_okay=False, resolve_path=True, path_type=Path), default=lambda: os.environ.get("ALGOKIT_LOCALNET_CONFIG_DIR", None), required=False, - help="Specify the custom localnet configuration directory.", + help=f"Specify the custom localnet configuration directory. Defaults to '{get_app_config_dir()}'.", ) @click.option( "--dev/--no-dev", @@ -180,11 +181,12 @@ def start_localnet(*, name: str | None, config_path: Path | None, algod_dev_mode if sandbox.is_algod_dev_mode() != algod_dev_mode: sandbox.set_algod_dev_mode(dev_mode=algod_dev_mode) if click.confirm( - f"Would you like to recreate 'algod' container to apply 'DevMode' flag set to '{algod_dev_mode}'? " + f"Would you like to restart 'LocalNet' to apply 'DevMode' flag set to '{algod_dev_mode}'? " "Otherwise, the next `algokit localnet reset` will restart with the new flag", default=True, ): - sandbox.recreate_container("algod") + sandbox.down() + sandbox.up() else: sandbox.up() diff --git a/src/algokit/core/_vendor/auth0/authentication/token_verifier.py b/src/algokit/core/_vendor/auth0/authentication/token_verifier.py index 4b9191fa..24b4e432 100644 --- a/src/algokit/core/_vendor/auth0/authentication/token_verifier.py +++ b/src/algokit/core/_vendor/auth0/authentication/token_verifier.py @@ -3,7 +3,6 @@ File ref: https://github.com/auth0/auth0-python/blob/master/auth0/authentication/token_verifier.py """ - from __future__ import annotations import json diff --git a/src/algokit/core/sandbox.py b/src/algokit/core/sandbox.py index ebd4f708..4caa7791 100644 --- a/src/algokit/core/sandbox.py +++ b/src/algokit/core/sandbox.py @@ -153,10 +153,20 @@ def compose_file_status(self) -> ComposeFileStatus: return ComposeFileStatus.OUT_OF_DATE return ComposeFileStatus.MISSING else: + algod_network_json_content = json.loads( + algod_network_template_content.replace("NUM_ROUNDS", '"NUM_ROUNDS"') + ) + latest_algod_network_json_content = json.loads( + self._latest_algod_network_template.replace("NUM_ROUNDS", '"NUM_ROUNDS"') + ) + + del algod_network_json_content["Genesis"]["DevMode"] + del latest_algod_network_json_content["Genesis"]["DevMode"] + if ( compose_content == self._latest_yaml and config_content == self._latest_config_json - and algod_network_template_content == self._latest_algod_network_template + and algod_network_json_content == latest_algod_network_json_content and proxy_config_content == self._latest_proxy_config ): return ComposeFileStatus.UP_TO_DATE @@ -195,21 +205,6 @@ def up(self) -> None: else: logger.warning("AlgoKit LocalNet failed to return a successful health check") - def recreate_container(self, container_name: str) -> None: - logger.info("Recreating the algod container to apply configuration changes...") - self._run_compose_command( - f"stop {container_name}", - bad_return_code_error_message=f"Failed to remove {container_name} container.", - ) - self._run_compose_command( - f"rm -f -v {container_name}", - bad_return_code_error_message=f"Failed to remove {container_name} container.", - ) - self._run_compose_command( - f"up -d {container_name}", - bad_return_code_error_message=f"Failed to recreate {container_name} container.", - ) - def stop(self) -> None: logger.info("Stopping AlgoKit LocalNet now...") self._run_compose_command("stop", bad_return_code_error_message="Failed to stop LocalNet")