[mypyc] property setter and deleter don't work with parameterized attributes
オープン
まだ誰も着手していません。
bug
topic-descriptors
topic-mypyc
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
mypyc fails to compile a class with a property setter and deleter and a weakref attribute.
To Reproduce
- Defined (in a file
foo.py) a classBarwith a property that has a setter and deleter and weakref attribute. - run
mypyc foo.py3.
e.g.
from __future__ import annotations
from typing import TypeVar, Generic
import weakref
T = TypeVar("T")
class Bar(Generic[T]):
_attr: weakref.ReferenceType[T] | None
def __init__(self) -> None:
self._attr = None
@property
def attr(self) -> T | None:
return self._attr() if self._attr is not None else None
@attr.setter
def attr(self, value: T) -> None:
self._attr = weakref.ref(value)
@attr.deleter
def attr(self) -> None:
self._attr = None
Actual Behavior
I get the following error:
File "mypyc/irbuild/classdef.py", line 87, in transform_class_def
File "mypyc/irbuild/classdef.py", line 200, in add_method
File "mypyc/irbuild/function.py", line 369, in handle_ext_method
File "mypyc/irbuild/function.py", line 312, in gen_func_item
File "mypyc/irbuild/function.py", line 351, in gen_func_ir
...: KeyError: <mypy.nodes.FuncDef object at 0x7f93d4876b80>
This error does not occur when setter and deleter are omitted.
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: 3.9
- Operating system and version: macOS Monterey, version 12.4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
foo.py の例で失敗を再現し、その後、報告されたパスを mypyc/irbuild/classdef.py と mypyc/irbuild/function.py を通して追跡します。property setter と deleter を持つパラメーター化された属性のカバレッジを追加し、mypyc foo.py が KeyError なしでコンパイルできれば issue 完了とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100