[mypyc] singledispatch made outside the main namespace
オープン
まだ誰も着手していません。
crash
topic-mypyc
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Mypyc cannot compile if there's a singledispatch function defined outside the main namespace, for example in the body of a function or class.
To Reproduce
- Make a file with the following contents
from __future__ import annotations
from functools import singledispatch, _SingleDispatchCallable
from typing import Any
def outer() -> _SingleDispatchCallable:
@singledispatch
def inner(obj: object) -> Any:
return 2
return inner
- Compile with
mypyc
Actual Behavior
Traceback (most recent call last):
File "mypyc/irbuild/builder.py", line 176, in accept
File "mypy/nodes.py", line 831, in accept
File "mypyc/irbuild/visitor.py", line 123, in visit_decorator
File "mypyc/irbuild/function.py", line 86, in transform_decorator
File "mypyc/irbuild/function.py", line 312, in gen_func_item
File "mypyc/irbuild/function.py", line 351, in gen_func_ir
src/.../mwe.py:8: KeyError: <mypy.nodes.FuncDef object at 0x10a7bfb80>
The error occurs at the location of the @singledispatch.
Your Environment
- Mypy version used: '0.950'
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: Python 3.10.4
- Operating system and version: macOS Monterey 12.5.1
https://github.com/python/mypy/issues/13613#tasklist-block-c661a68b-595f-4b41-98a7-bf6bcaf6e3d9
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供されている singledispatch のネストした例と mypyc を使って失敗を再現します。mypy/irbuild/visitor.py の visit_decorator から始め、続いて mypyc/irbuild/function.py の transform_decorator、gen_func_item、gen_func_ir を追ってください。mypyが報告された KeyError なしで例をコンパイルできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100