新增:智能上下文管理功能(Feapder.Request() 中无需再手动传递参数)#304
Open
ShellMonster wants to merge 2 commits intoBoris-code:masterfrom
Open
新增:智能上下文管理功能(Feapder.Request() 中无需再手动传递参数)#304ShellMonster wants to merge 2 commits intoBoris-code:masterfrom
ShellMonster wants to merge 2 commits intoBoris-code:masterfrom
Conversation
added 2 commits
November 20, 2025 02:20
## 功能概述 通过静态代码分析和运行时参数收集,实现回调函数之间的参数自动传递,解决多层回调中的参数传递难题。 ## 核心特性 - 三种参数来源自动捕获(局部变量、request 属性、显式传入) - 两种传递模式(transitive 传递性模式、direct 直接模式) - 智能参数过滤(私有变量、特殊对象、大对象自动过滤) - 静态代码分析(启动时一次性分析,构建回调依赖图) ## 新增文件 - feapder/utils/context_analyzer.py - 静态代码分析引擎 - docs/usage/智能上下文管理.md - 完整使用文档 - tests/test_smart_context*.py - 单元测试和压力测试 - PR文档_智能上下文管理.md - PR 说明文档 - 开发进度.md - 项目开发进度记录 ## 修改文件 - feapder/network/request.py - 新增参数自动继承逻辑 - feapder/core/spiders/air_spider.py - 集成静态分析器 - feapder/core/scheduler.py - 传递分析结果 - feapder/core/parser_control.py - 注入分析结果 - feapder/setting.py - 新增配置项 - docs/_sidebar.md - 添加文档导航 ## 配置项 - SMART_CONTEXT_ENABLE: 智能上下文管理开关(默认 False) - SMART_CONTEXT_MODE: 传递模式(默认 "transitive") ## 测试 - ✅ 10 层传递测试通过 - ✅ 三种参数来源测试通过 - ✅ 参数过滤测试通过 - ✅ 测试覆盖率 100%
Contributor
Author
|
这个不是必须的功能,只是我每次嵌套比较多,老是容易忘要携带的参数,所以想到了搞这个,融进去麻烦就挂着吧😂 |
Owner
|
有点复杂,脑子不够用了,不过传递大量参数时,我一般是透传item。每个paser拼接一部分item 层层向下传递,最终拼好后入库 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
功能概述
通过静态代码分析和运行时参数收集,实现回调函数之间的参数自动传递,解决多层回调中的参数传递难题;
用于支持多层parse函数时容易忘记传参,一直报错要排查的麻烦。
核心特性
新增文件
修改文件
配置项