mypy RecursionError analyzing pint.facets.plain.quantity.PlainQuantity
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
首先,在匯入 pint.facets.plain.quantity.PlainQuantity 的檔案中使用 mypy 重現當機。追蹤經過所提及路徑 type_visitor.py 和 types.py 的遞迴,然後驗證對相同匯入的分析能夠在沒有 RecursionError 的情況下完成。
由索引模型根據 Issue 內容生成。
描述
Crash Report
mypy crashes with RecursionError while analyzing pint (since pint==0.26.1). Reproduced with compiled and non-compiled mypy.
Traceback
... skipping approx 50000 lines ...
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 560, in visit_instance
return self.query_types(t.args)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in query_types
return any(t.accept(self) for t in types)
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in <genexpr>
return any(t.accept(self) for t in types)
~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/types.py", line 1684, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 560, in visit_instance
return self.query_types(t.args)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in query_types
return any(t.accept(self) for t in types)
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in <genexpr>
return any(t.accept(self) for t in types)
~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/types.py", line 1684, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 560, in visit_instance
return self.query_types(t.args)
~~~~~~~~~~~~~~~~^^^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in query_types
return any(t.accept(self) for t in types)
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/type_visitor.py", line 628, in <genexpr>
return any(t.accept(self) for t in types)
~~~~~~~~^^^^^^
File "/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/mypy/types.py", line 1684, in accept
return visitor.visit_instance(self)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^
RecursionError: maximum recursion depth exceeded
/home/quentin/dev/QSA/pint_0.x/.venv/lib/python3.13/site-packages/pint/facets/numpy/quantity.py:63: note: use --pdb to drop into pdb
RecursionError: maximum recursion depth exceeded
To Reproduce
I narrowed down the issue to this single import of pint.facets.plain.quantity.PlainQuantity.
Run mypy on a file with this content:
from pint.facets.plain.quantity import PlainQuantity
Your Environment
Issue appears since version 0.26 of pint when they introduced massive type annotations for PlainQuantity. See https://github.com/hgrecco/pint/pull/2302 and https://github.com/hgrecco/pint/pull/2303
- Mypy version used:
2.3.1and1.9.1 - Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used:
3.13.12 - Operating system and version: Fedora 43 in WSL2
- 主要語言
- Python
- 星號
- 20.6k
- 分支
- 3.3k
- 平均合併
- 1 天 3 小時
- 30 天內合併 PR
- 64
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
python/mypy 的其他 Issue
-
bug documentation
難度 1/5 1 小時以內 新手友好度 90/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
維護者通常 1 天內回覆
-
documentation
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
bug topic-configuration topic-error-reporting
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 84/100
PedestrianDynamics/pyFDS-Evac#343 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
theskumar/python-dotenv#708 ·
-
難度 1/5 1 小時以內 新手友好度 88/100
維護者通常 2 天內回覆
-
Docs Timedelta
難度 2/5 1-3 小時 新手友好度 72/100
pandas-dev/pandas#69919 ·
維護者通常 1 天內回覆
-
API documentation
難度 2/5 1-3 小時 新手友好度 72/100
zephyrproject-rtos/west#1009 · 2 則留言 ·
維護者通常 3 天內回覆