Python: a test inside a package misses imports that resolve from its basedir
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 84/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- python, typescript
研究方向
從 src/repo/adapters/python.ts 中的 resolvePythonGraph 和逐檔的 fileRoots 邏輯開始。閱讀現有的 Python 圖測試,並新增一個符合 issue 中 services/api/tests 套件配置的案例,其中 test_app.py 匯入同目錄下的 app。完成標準是:變更 services/api/app.py 時會選取該測試,且端對端分析會將其回報為受影響項。
由索引模型根據 Issue 內容生成。
描述
resolvePythonGraph (src/repo/adapters/python.ts, the fileRoots line in the per-file loop) adds a file's own directory to the import roots only when that directory has no __init__.py. pytest's default prepend import mode puts the file's basedir on sys.path: the first directory above the file's package. A test inside a package below the repository root can import modules beside that package, and DiffCI misses the edge.
pyproject.toml [tool.pytest.ini_options]
services/api/app.py def f(): return 1
services/api/tests/__init__.py
services/api/tests/test_app.py import app
python -m pytest services/api/tests/test_app.py passes (pytest 9.2).
Expected: a change to services/api/app.py selects services/api/tests/test_app.py.
Actual: no edge and no blocker (app is not first-party when seen from the root), so the change is selective with no tests:
resolvePythonGraph(
["services/api/app.py", "services/api/tests/__init__.py", "services/api/tests/test_app.py"],
{ "services/api/app.py": { imports: [] }, "services/api/tests/__init__.py": { imports: [] },
"services/api/tests/test_app.py": { imports: [["app", 0, []]] } },
{ pythonFiles: ["test_*.py"], testpaths: [], pythonpath: [] },
new Set(["services/api/tests/test_app.py"]),
); // { edges: [], blockers: [] }
End to end, ImpactAnalyzer returns fallbackRequired: false and no affected tests.
Fix: resolve against the basedir: the file's directory when it is not a package, otherwise the nearest ancestor without __init__.py.
- 主要語言
- TypeScript
- 星號
- 0
- 分支
- 4
- 平均合併
- 18 小時 41 分鐘
- 30 天內合併 PR
- 48
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
DiffCI/core 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
Planner: splitParts regex is quadratic on a quote followed by many backticks, so the fuzz test fails at random可能已有人在做 @FredApps 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 86/100
維護者通常 1 天內回覆
-
Agent tools: changed_files lists only the new path of a renamed file可能已有人在做 @FredApps 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
adapter good first issue
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
adapter bug good first issue
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
相似的 Issue
-
agent-ready area: ui-server priority: p3 type: test
難度 2/5 1-3 小時 新手友好度 78/100
schlessera/brain-kit#4249 ·
維護者通常 1 天內回覆
-
documentation tool triaged
難度 2/5 1-3 小時 新手友好度 73/100
can1357/oh-my-pi#19608 · 2 則留言 ·
維護者通常 1 天內回覆
-
dependencies tech-debt
難度 2/5 1-3 小時 新手友好度 65/100
bcgov/nr-waste-plus#1549 ·
維護者通常 1 天內回覆
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 78/100
blixvip/solana-token-meta#17 ·
-
enhancement good first issue
難度 2/5 1-3 小時 新手友好度 78/100
blixvip/solana-tx-parse#18 ·