[mypyc] cannot compile parameterized dataclass
オープン
まだ誰も着手していません。
bug
topic-dataclasses
topic-mypyc
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 54
説明
Bug Report
mypyc can compile a parameterized dataclass, but it fails at import.
To Reproduce
- Make a file with
from __future__ import annotations
from dataclasses import dataclass
from typing import TypeVar, Generic
T = TypeVar("T")
class Foo(Generic[T]):
pass
@dataclass
class Bar(Foo[T]):
x: T
@property
def also_x(self) -> T:
return self.x
- Compile with mypyc (it appears that it works)
- Try importing Bar from file (to discover it does not work)
Actual Behavior
AttributeError Traceback (most recent call last)
...
----> 1 from test import Bar
File ~/.../test.py:15, in <module>
10 class Foo(Generic[T]):
11 pass
14 @dataclass
---> 15 class Bar(Foo[T]):
17 x: T
19 @property
20 def also_x(self) -> T:
AttributeError: attribute '__dict__' of 'type' objects is not writable
Your Environment
- Mypy version used: '0.950'
- Mypy command-line flags:
--strict - Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used: 3.9.12
- Operating system and version: macOS Monterey 12.4
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
test.py にあるパラメーター化された dataclass の reproducer から始め、報告されている Python と mypy のバージョンを使って mypyc でコンパイルします。生成されたモジュールのインポート動作と、dataclass、Generic[T]、property の相互作用を確認します。Bar を AttributeError なしでインポートできれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100