Experiment with backtracking in the new solver
還沒有人認領這個 Issue。
評估
研究方向
首先閱讀 issue #15906 以及 pull request #15287 中的後續系列,以了解已在進行的 solver 變更。然後檢查此 issue 中的型別變數約束範例,並確定回溯實驗的範圍。完成這項工作需要達成共識的設計,並提供有關推論失敗和最壞情況行為的證據。
由索引模型根據 Issue 內容生成。
描述
Depend on https://github.com/python/mypy/issues/15906. This is a follow-up for series started by https://github.com/python/mypy/pull/15287
Currently when getting both upper and lower bounds for a type variable we randomly choose the lower one. This is not always the best choice and can lead to inference failures. A possible example is:
def dec(fn: Callable[[S, S, int], float]) -> Callable[[S], float]: ...
def f(x: List[float], y: List[T], z: T) -> T: ...
dec(f)
this will infer constraints like
S <: List[float], S <: List[T], T <: float, T :> int
They split into two SCCs each containing one variable {T} and {S}, and the second depends on first one. So we would first solve T = int and then we will get updated constraints for S: S <: List[float], S <: List[int], with the only solution S = <nothing>. At the same time T = float, S = List[float] is a totally valid solution. We could get it by backtracking when we get <nothing> and trying different bound(s) in the previous SCC.
One possible problem I see is that this backtracking is exponential in worst case of inference failure (e.g. due to actual user error). Another problem is that backtracking can make implementation much less readable.
cc @JukkaL
- 主要語言
- Python
- 星號
- 20.6k
- 分支
- 3.3k
- 平均合併
- 1 天 18 小時
- 30 天內合併 PR
- 54
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/mypy 的其他 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 75/100
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
-
documentation
難度 2/5 1-3 小時 新手友好度 72/100
-
bug topic-configuration topic-error-reporting
難度 2/5 1-3 小時 新手友好度 68/100
相似的 Issue
-
area/auth bug comp/agent P3 platform/discord type/security
難度 2/5 1-3 小時 新手友好度 88/100
NousResearch/hermes-agent#117848 ·
-
難度 2/5 1-3 小時 新手友好度 74/100
bancolombia/sentinel#23 ·
-
test md 未關閉CI
難度 2/5 1-3 小時 新手友好度 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難度 2/5 1-3 小時 新手友好度 74/100
langchain-ai/deepagents#6450 ·
-
bug client
難度 2/5 1-3 小時 新手友好度 88/100