Skip to content

Instantly share code, notes, and snippets.

View Rohan5commit's full-sized avatar

Rohan Santhosh Kumar Rohan5commit

  • Singapore
View GitHub Profile
@Rohan5commit
Rohan5commit / ADOPTION_ISSUE_TEMPLATE.md
Last active May 2, 2026 03:18
Official Framework Adoption Proposal: Web3.py Codemod

Official Adoption Proposal: Web3.py v6 to v7 Migration Codemod

To: The Maintainers of ethereum/web3.py (and ecosystem frameworks like ApeWorX/ape)

The Problem

Migrating to Web3.py v7 introduces significant architectural breaking changes. The deprecation of functional middleware in favor of Web3Middleware classes, combined with the WebsocketProviderV2 and .ws -> .socket renaming, creates a high friction barrier for adoption. A typical ecosystem project requires days of manual refactoring to compile against v7.

The Solution

We have built and submitted a production-grade, AST-driven codemod to the official codemod.com registry that safely automates ~90% of the v6 to v7 migration path.

@Rohan5commit
Rohan5commit / CASE_STUDY.md
Last active May 2, 2026 03:14
Web3.py v6 to v7 Migration: A Case Study (Codemod)

Python Web3.py v6 to v7 Migration: A Codemod Case Study

Target Ecosystem: Python Web3.py Project Migrated: simulated-ape-core (A subset of complex middleware and provider integrations mimicking the ApeWorX/ape web3 framework).

1. The Migration Approach: Determinism First, AI Second

The transition from Web3.py v6 to v7 introduces massive breaking changes, particularly the complete deprecation of functional middleware in favor of class-based architectures, alongside sweeping renaming of core providers (WebsocketProviderV2 -> WebSocketProvider) and namespaces (.ws -> .socket).

Our strategy balances pure Abstract Syntax Tree (AST) parsing with Generative AI:

  1. JSSG (ast-grep) Layer: We mapped over 15 distinct v7 breaking changes (Providers, Exceptions, Types) directly to Tree-Sitter AST transforms. By abandoning brittle regex and string splitting in favor of native Python syntax trees, this layer mathematically guarantees Zero False Positives.