From 3bb529318fc781386ab1d2c01e3c92c2e8d9c4a7 Mon Sep 17 00:00:00 2001 From: grapebaba <281165273@qq.com> Date: Sun, 27 Aug 2023 21:26:01 +0800 Subject: [PATCH 1/2] feat:add autopep8 format Signed-off-by: grapebaba <281165273@qq.com> --- Makefile | 6 +++++- README.md | 3 +++ l1.py | 6 +++--- scripts/install.sh | 9 +++++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 5769af5..4bd75fd 100644 --- a/Makefile +++ b/Makefile @@ -3,4 +3,8 @@ linter: ## Run linter .PHONY: linter check: linter ## Run check -.PHONY: check \ No newline at end of file +.PHONY: check + +format: ## Run format + @autopep8 --in-place --recursive . --exclude optimism,op-geth,venv --max-line-length 120 +.PHONY: format \ No newline at end of file diff --git a/README.md b/README.md index 4fde0a0..04cd966 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,9 @@ always for your permission before installing anything outside the current direct # Install dependencies source scripts/install.sh +# Run format before committing +make format + # Run checks make check ``` diff --git a/l1.py b/l1.py index 861e33a..58341c1 100644 --- a/l1.py +++ b/l1.py @@ -16,8 +16,7 @@ sys.path.append("optimism/bedrock-devnet/devnet") # noinspection PyUnresolvedReferences -from genesis import GENESIS_TMPL - +from genesis import GENESIS_TMPL # noqa: E402 #################################################################################################### @@ -171,7 +170,8 @@ def start_devnet_l1_node(paths: OPPaths): except Exception: running = False if running: - raise Exception("Couldn't start L1 node: server already running at localhost:8545") + raise Exception( + "Couldn't start L1 node: server already running at localhost:8545") # Create geth db if it doesn't exist. os.makedirs(DEVNET_L1_DATA_DIR, exist_ok=True) diff --git a/scripts/install.sh b/scripts/install.sh index 067ecac..877729c 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -46,6 +46,15 @@ install_dev_dependencies() { echo "ruff version is $ruff_version, but 0.0.286 is required" pip3 install ruff==0.0.286 fi + + # Check if autopep8 is installed, otherwise install it + if ! command -v autopep8 &> /dev/null + then + echo "autopep8 could not be found, installing it now" + pip3 install --upgrade autopep8 + else + echo "autopep8 is installed" + fi } check_python_version From 7855716c0c3b37ae750e14e022e7159e4f65f769 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Norswap\" Laurent" Date: Fri, 1 Sep 2023 22:42:47 +0900 Subject: [PATCH 2/2] check autopep8 version, downgrade pip3 version to the one that mine will not upgrade past --- l1.py | 3 +-- scripts/install.sh | 17 +++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/l1.py b/l1.py index 58341c1..c828f3c 100644 --- a/l1.py +++ b/l1.py @@ -170,8 +170,7 @@ def start_devnet_l1_node(paths: OPPaths): except Exception: running = False if running: - raise Exception( - "Couldn't start L1 node: server already running at localhost:8545") + raise Exception("Couldn't start L1 node: server already running at localhost:8545") # Create geth db if it doesn't exist. os.makedirs(DEVNET_L1_DATA_DIR, exist_ok=True) diff --git a/scripts/install.sh b/scripts/install.sh index 877729c..b8b2e4b 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -30,14 +30,16 @@ activate_venv() { install_dev_dependencies() { # Install development dependencies echo "installing development dependencies" - # Check if pip3 version is greater or equal than 21.2.4, otherwise upgrade it + + # Check if pip3 version is greater or equal than 21.2.1, otherwise upgrade it pip3_version=$(pip3 --version | awk '{print $2}') - if python3 -c "import sys; sys.exit(not (sys.version_info >= (21, 2, 4)))"; then + if python3 -c "import sys; sys.exit(not (sys.version_info >= (21, 2, 1)))"; then echo "pip3 version is $pip3_version" else - echo "pip3 version is $pip3_version, but 21.2.4 or greater is required" + echo "pip3 version is $pip3_version, but 21.2.1 or greater is required" pip3 install --upgrade pip fi + # Check if ruff 0.0.286 is installed, otherwise install this version ruff_version=$(pip3 freeze | grep ruff | awk -F'==' '{print $2}') if [ "$ruff_version" = "0.0.286" ]; then @@ -48,10 +50,13 @@ install_dev_dependencies() { fi # Check if autopep8 is installed, otherwise install it - if ! command -v autopep8 &> /dev/null - then + autopep8_version=2.0.4 + if ! command -v autopep8 &> /dev/null; then echo "autopep8 could not be found, installing it now" - pip3 install --upgrade autopep8 + pip3 install autopep8==$autopep8_version + elif [ "$(autopep8 --version | awk '{print $2}')" != $autopep8_version ]; then + echo "forcing autopep8 to right version" + pip3 install autopep8==$autopep8_version else echo "autopep8 is installed" fi