Mypyc runtime TypeError exceptions when you change inherited method to a staticmethod
オープン
まだ誰も着手していません。
bug
topic-mypyc
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Crash Report
Using mypyc to compile an ABC subclass with @classmethod and implement it in a subclass as @staticmethod leads to runtime type exceptions.
checkers_minimax.py
from abc import ABC
class State:
"""State object."""
class MinimaxWithTT(ABC):
@classmethod
def terminal(cls, state: State) -> bool:
return False
def alphabeta_transposition_table(
self,
state: State,
) -> None:
print(f"Just before crash {type(state) = }")
self.terminal(state)
class CheckersMinimax(MinimaxWithTT):
@staticmethod
def terminal(state: State) -> bool:
return False
def run() -> None:
mm = CheckersMinimax()
mm.alphabeta_transposition_table(State())
if __name__ == "__main__":
run()
mypyc checkers_minimax.py
python -c "from checkers_minimax import run; run()"
Traceback
Traceback (most recent call last):
File "<string>", line 1, in <module>
from checkers_minimax import run; run()
~~~^^
File "checkers_minimax.py", line 29, in run
mm.alphabeta_transposition_table(State())
File "checkers_minimax.py", line 18, in alphabeta_transposition_table
self.terminal(state)
TypeError: checkers_minimax.State object expected; got abc.ABCMeta
To Reproduce
See above
Your Environment
- Mypy version used:
mypy 1.17.1 (compiled: yes) - Mypy command-line flags: See above
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: Python 3.13.3 (main, Jun 16 2025, 18:15:32) [GCC 14.2.0] on linux
- Operating system and version:
> uname -a
Linux ideapad 6.14.0-24-generic #24-Ubuntu SMP PREEMPT_DYNAMIC Sun Jun 15 11:18:07 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
- GCC version
> x86_64-linux-gnu-gcc --version
x86_64-linux-gnu-gcc (Ubuntu 14.2.0-19ubuntu2) 14.2.0
...
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
checkers_minimax.py で再現から始め、ドキュメントに記載された mypyc コマンドを実行した後、Python の呼び出しを実行します。継承された classmethod が staticmethod としてオーバーライドされる場合の mypyc の処理を追跡します。完了条件は、コンパイルされたプログラムが報告された TypeError なしで実行され、適切なテストによってリグレッションがカバーされることです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- compilers, devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100