Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:add autopep8 format #31

Merged
merged 2 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,8 @@ linter: ## Run linter
.PHONY: linter

check: linter ## Run check
.PHONY: check
.PHONY: check

format: ## Run format
@autopep8 --in-place --recursive . --exclude optimism,op-geth,venv --max-line-length 120
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually go for 100 as line length. Do you have strong opinions on 120?

.PHONY: format
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
3 changes: 1 addition & 2 deletions l1.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

####################################################################################################

Expand Down
20 changes: 17 additions & 3 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -46,6 +48,18 @@ 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
autopep8_version=2.0.4
if ! command -v autopep8 &> /dev/null; then
echo "autopep8 could not be found, installing it now"
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably also want version checks here to avoid random breakage in CI.

}

check_python_version
Expand Down