惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
有赞技术团队
有赞技术团队
H
Help Net Security
V
Visual Studio Blog
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Stack Overflow Blog
Stack Overflow Blog
I
InfoQ
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
L
LangChain Blog
N
Netflix TechBlog - Medium
罗磊的独立博客
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
Hugging Face - Blog
Hugging Face - Blog
A
About on SuperTechFans
aimingoo的专栏
aimingoo的专栏
Recent Announcements
Recent Announcements

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
How I Automated the Web3.py v6 to v7 Migration with AST + AI
ROHAN SANTHO · 2026-05-02 · via DEV Community

ROHAN SANTHOSH

Web3.py v7 introduced a migration problem that was much more painful than a normal dependency upgrade. It changed middleware architecture, provider names, exception imports, and namespace usage in ways that can easily break production code if migrated mechanically.

I built Web3.py v7 Zero-BS Migrator to automate that upgrade with a hybrid approach: deterministic AST transforms for statically provable changes, and a tightly scoped AI rewrite layer only for middleware patterns that cannot be translated safely with pure syntax rules.

Project links:

The problem

The biggest breaking change in Web3.py v7 was the move from functional middleware to class-based middleware. That means many existing codebases cannot be upgraded with simple search-and-replace logic, because middleware often contains custom logic and project-specific behavior.

The migration also includes changes such as WebsocketProviderV2 to WebSocketProvider, .ws to .socket, and updates around exceptions and AttributeDict. Across a real codebase, those changes are repetitive, easy to miss, and expensive to review manually.

The design

I used a two-layer system.

Layer 1: deterministic AST transforms

The first layer uses Tree-Sitter-based AST transforms to handle migration patterns that can be converted deterministically. This covers provider renames, exception import adjustments, AttributeDict changes, and namespace updates like .ws to .socket.

If a transformation can be proven from syntax alone, it should be done with a deterministic rule rather than AI.

Layer 2: scoped AI for middleware migration

The second layer is reserved only for functional middleware, where deterministic translation is not enough. The tool uses a sandboxed NVIDIA NIM Llama-3-70B rewrite applied only to the relevant function node instead of the whole file.

That keeps the AI component constrained to the one area where it adds real value, while safety controls such as context injection, indentation tracking, retry logic, and deprecation handling keep the rewrite usable in practice.

Results

The evaluation numbers were:

  • 120-file test suite.
  • 142 total patterns found.
  • 130 automated.
  • 91.5% automation coverage.
  • 0 false positives.
  • 98.59 evaluation score.

The key lesson is simple: use deterministic transforms wherever possible, and use AI only where the migration is architectural rather than purely syntactic.intent.

If a migration tool can respect that boundary, it can be both fast and trustworthy. That was the goal of Web3.py v7 Zero-BS Migrator.
In practical terms, this means teams upgrading from Web3.py v6 to v7 can automate the bulk of the migration quickly, while still treating custom middleware as a controlled and reviewable rewrite step.

Demo and links

Closing note

The main lesson from building this was that migration tooling works best when it separates deterministic code transformation from architectural judgment. Web3.py v7 is a good example of why that distinction matters: some breaking changes are simple rewrites, while others require a deeper understanding of intent. [page:1]

If a migration tool can respect that boundary, it can be both fast and trustworthy. That was the goal of Web3.py v7 Zero-BS Migrator. [page:1]