Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/commitlint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
19 changes: 8 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -26,14 +26,11 @@ jobs:
python -m pip install --upgrade pip
pip install .[lint]

- name: Run Black
run: black --check .
- name: Run Ruff Lint
run: ruff check .

- name: Run isort
run: isort --check-only .

- name: Run flake8
run: flake8 .
- name: Run Ruff Format
run: ruff format --check .

- name: Run mdformat
run: mdformat . --check
Expand All @@ -42,7 +39,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -66,7 +63,7 @@ jobs:
python-version: [3.9, "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup Python
uses: actions/setup-python@v5
Expand All @@ -89,7 +86,7 @@ jobs:
# fail-fast: true
#
# steps:
# - uses: actions/checkout@v4
# - uses: actions/checkout@v5
#
# - name: Setup Python
# uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/title.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Setup Python
uses: actions/setup-python@v5
Expand Down
20 changes: 5 additions & 15 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,12 @@ repos:
hooks:
- id: check-yaml

- repo: https://github.com/PyCQA/isort
rev: 5.13.2
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.12.0 # Latest ruff version
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 7.1.1
hooks:
- id: flake8
additional_dependencies: [flake8-breakpoint, flake8-print, flake8-pydantic, flake8-type-checking]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- id: ruff-format

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
Expand Down
20 changes: 17 additions & 3 deletions ape_arbitrum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,27 @@ def providers():


def __getattr__(name: str):
import ape_arbitrum.ecosystem as module
if name == "Arbitrum":
from .ecosystem import Arbitrum

return getattr(module, name)
return Arbitrum

elif name == "ArbitrumConfig":
from .ecosystem import ArbitrumConfig

return ArbitrumConfig

elif name == "NETWORKS":
from .ecosystem import NETWORKS

return NETWORKS

else:
raise AttributeError(name)


__all__ = [
"NETWORKS",
"Arbitrum",
"ArbitrumConfig",
"NETWORKS",
]
22 changes: 18 additions & 4 deletions ape_arbitrum/ecosystem.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import time
from typing import ClassVar, cast

from eth_pydantic_types import HexBytes
from pydantic.fields import Field

from ape.api.transactions import ConfirmationsProgressBar, ReceiptAPI, TransactionAPI
from ape.exceptions import ApeException, TransactionError
from ape.logging import logger
Expand All @@ -14,8 +17,6 @@
TransactionStatusEnum,
)
from ape_ethereum.transactions import TransactionType as EthTransactionType
from eth_pydantic_types import HexBytes
from pydantic.fields import Field

NETWORKS = {
# chain_id, network_id
Expand Down Expand Up @@ -143,7 +144,14 @@ def create_transaction(self, **kwargs) -> TransactionAPI:
tx_data = _correct_key(
"type",
tx_data,
("txType", "tx_type", "txnType", "txn_type", "transactionType", "transaction_type"),
(
"txType",
"tx_type",
"txnType",
"txn_type",
"transactionType",
"transaction_type",
),
)

# Handle unique value specifications, such as "1 ether".
Expand Down Expand Up @@ -235,7 +243,13 @@ def decode_receipt(self, data: dict) -> ReceiptAPI:
status = TransactionStatusEnum(status)

txn_hash = None
hash_key_choices = ("hash", "txHash", "txnHash", "transactionHash", "transaction_hash")
hash_key_choices = (
"hash",
"txHash",
"txnHash",
"transactionHash",
"transaction_hash",
)
for choice in hash_key_choices:
if choice in data:
txn_hash = data[choice]
Expand Down
146 changes: 117 additions & 29 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,124 @@ plugins = ["pydantic.mypy"]
[tool.setuptools_scm]
write_to = "ape_arbitrum/version.py"

# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.

[tool.black]
[tool.ruff]
target-version = "py39"
line-length = 100
target-version = ['py39', 'py310', 'py311', 'py312']
include = '\.pyi?$'

[tool.pytest.ini_options]
addopts = """
-p no:ape_test
-p no:pytest_ethereum
--cov-branch
--cov-report term
--cov-report html
--cov-report xml
--cov=ape_arbitrum
"""
python_files = "test_*.py"
testpaths = "tests"
markers = "fuzzing: Run Hypothesis fuzz test suite"

[tool.isort]
line_length = 100
force_grid_wrap = 0
include_trailing_comma = true
multi_line_output = 3
use_parentheses = true

[tool.ruff.lint]
# Select rule categories to enforce
select = [
# Core Python errors and style
"E", # pycodestyle errors
"F", # pyflakes
"W", # pycodestyle warnings
"I", # isort
"B", # flake8-bugbear - common bugs/design issues
"C4", # flake8-comprehensions - simplify comprehensions
"UP", # pyupgrade - modern Python features/idioms
"RET", # flake8-return - cleaner return statements
"SIM", # flake8-simplify - code simplification
"S", # flake8-bandit - security issues
"TCH", # flake8-type-checking - type annotation improvements
"T10", # flake8-debugger - detect debugger calls/imports
"FIX", # flake8-fixme - detect FIXME, TODO, XXX comments
]

# Rules to ignore
ignore = [
"E501",

# Specific bugbear issues
"B904", # Use 'raise from' in except blocks
"B006", # Mutable default arguments
"B007", # Loop control variable not used within loop body
"B012", # Jump statements in finally blocks
"B028", # No explicit stacklevel in warnings

# FIXME/TODO comments - these are intentional markers for future work
"FIX002", # Line contains TODO
"FIX004", # Line contains HACK

# Code structure preferences
"SIM102", # Use a single if statement instead of nested if statements
"SIM105", # Use contextlib.suppress instead of try-except-pass
"SIM108", # Use ternary operator instead of if-else block
"SIM113", # Use enumerate instead of manually incrementing counter
"SIM114", # If branches with identical arm bodies (combine with or)
"SIM115", # Use context manager for opening files
"SIM116", # Use dictionary instead of if-statements
"SIM117", # Multiple with statements
"B018", # Useless expression

# Return statement style
"RET501", # Do not explicitly return None
"RET502", # Implicit return at the end of function able to return non-None value
"RET503", # Missing explicit return at the end of function able to return non-None value
"RET504", # Unnecessary assignment before return
"RET505", # Unnecessary else after return
"RET506", # Unnecessary else after raise
"RET507", # Unnecessary else after continue
"RET508", # Unnecessary else after break

# Security issues (allow common patterns in the codebase)
"S101", # Use of assert (many asserts are used for type checking)
"S102", # Use of exec (needed in some specific places)
"S105", # Hardcoded password string
"S110", # Try-except-pass (common pattern for handling optional features)
"S112", # Try-except-continue
"S113", # Request without timeout
"S202", # Tarfile unsafe members
"S307", # Use of eval
"S311", # Suspicious non-cryptographic random usage
"S603", # Subprocess without shell=True
"S607", # Start process with partial path

# Style/readability issues (improve incrementally)
"C416", # Unnecessary comprehension (rewrite using list/set/dict)
"C408", # Unnecessary dict() call (rewrite as literal)
"C417", # Unnecessary map usage (replace with generator)
"C414", # Unnecessary list/dict call within another function
"C401", # Unnecessary generator (rewrite as comprehension)
"C409", # Unnecessary literal within tuple/list/dict call
"C419", # Unnecessary comprehension in call
"SIM101", # Duplicate isinstance call
"SIM103", # Needless boolean conversion
"SIM110", # Reimplemented builtin
"SIM118", # Use 'key in dict' instead of 'key in dict.keys()'
"SIM401", # Use dict.get instead of if-else block
"SIM910", # Use dict.get(key) instead of dict.get(key, None)
"TC001", # Move application import into type-checking block
"TC003", # Move standard library import into type-checking block
"TC006", # Add quotes to type expression in `typing.cast()`
"UP028", # Replace yield over for loop with yield from
]

[tool.ruff.lint.per-file-ignores]
"**/tests/**/*.py" = [
"D", # Don't require docstrings in tests
"E501", # Line length in tests is less critical
"S101", # Allow assert in tests
"B011", # Allow assert False in tests (common pattern)
]
"**/conftest.py" = [
"F401", # Unused imports in conftest.py are often for fixtures
"F841", # Allow unused variables in conftest (often for fixture side effects)
]
"**/tests/integration/cli/projects/**/*.py" = [
"F841", # These are test files that intentionally create errors
]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.isort]
known-first-party = ["ape", "ape_accounts", "ape_console", "ape_ethereum", "ape_geth", "ape_networks", "ape_node", "ape_plugins", "ape_pm", "ape_test", "ape_arbitrum"]

[tool.ruff.format]
quote-style = "double"
line-ending = "auto"
indent-style = "space"
docstring-code-format = true

[tool.mdformat]
number = true
13 changes: 3 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from setuptools import find_packages, setup

extras_require = {
Expand All @@ -11,19 +10,13 @@
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
],
"lint": [
"black>=24.10.0,<25", # Auto-formatter and linter
"ruff>=0.12.0", # Unified linter and formatter
"mypy>=1.13.0,<2", # Static type analyzer
"types-setuptools", # Needed for mypy type shed
"flake8>=7.1.1,<8", # Style linter
"flake8-breakpoint>=1.1.0,<2", # Detect breakpoints left in code
"flake8-print>=5.0.0,<6", # Detect print statements left in code
"flake8-pydantic", # For detecting issues with Pydantic models
"flake8-type-checking", # Detect imports to move in/out of type-checking blocks
"isort>=5.13.2,<6", # Import sorting linter
"mdformat>=0.7.1", # Auto-formatter for markdown
"mdformat>=0.7.19", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
"mdformat-frontmatter>=0.4.1", # Needed for frontmatters-style headers in issue templates
"mdformat-pyproject>=0.0.1", # Allows configuring in pyproject.toml
"mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml
],
"doc": [
"myst-parser>=1.0.0,<2", # Parse markdown docs
Expand Down
3 changes: 2 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import ape
import pytest

import ape


@pytest.fixture(autouse=True)
def eth_tester_provider():
Expand Down
3 changes: 1 addition & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ape_ethereum.transactions import TransactionType

from ape_arbitrum.ecosystem import LOCAL_GAS_LIMIT, ArbitrumConfig
from ape_ethereum.transactions import TransactionType


def test_gas_limit(arbitrum):
Expand Down
Loading
Loading