Mypy signals error with Protocol and __rpow__ method with three arguments
オープン
まだ誰も着手していません。
bug
good-first-issue
topic-protocols
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Okay, this is a head-scratcher. 😕
To Reproduce
# test_case.py
from typing import Protocol, overload, runtime_checkable
@runtime_checkable
class PowableProto(Protocol):
@overload
def __pow__(self, other: "PowableProto") -> "PowableProto":
...
@overload
def __pow__(self, other: "PowableProto", modulo: "PowableProto") -> "PowableProto": # <- fine
...
@overload
def __rpow__(self, other: "PowableProto") -> "PowableProto":
...
@overload
def __rpow__(self, other: "PowableProto", modulo: "PowableProto") -> "PowableProto": # <- this (of all things) breaks
...
@overload
def __rpOw__(self, other: "PowableProto") -> "PowableProto":
...
@overload
def __rpOw__(self, other: "PowableProto", modulo: "PowableProto") -> "PowableProto": # <- fine
...
% mypy --version
mypy 0.910
% mypy --config-file=/dev/null test_case.py
/dev/null: No [mypy] section in config file
test_case.py:15: error: Invalid signature "def (test_case.PowableProto, test_case.PowableProto, test_case.PowableProto) -> test_case.PowableProto"
Found 1 error in 1 file (checked 1 source file)
Expected vs. Actual Behavior
I would expect at least consistent behavior among the overridden methods. This only crops up with __rpow__ for some reason. (I have tested many others.)
Your Environment
- Mypy version used: 0.910
- Mypy command-line flags:
--config-file=/dev/null(i.e., force default configuration) - Mypy configuration options from
mypy.ini(and other config files): N/A - Python version used:
Python 3.9.6(frompython --version) - Operating system and version:
Darwin Kernel Version 19.6.0: Thu May 6 00:48:39 PDT 2021; root:xnu-6153.141.33~1/RELEASE_X86_64(fromuname -v)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された mypy コマンドを test_case.py に対して実行し、3 引数の pow と rpow のオーバーロードがどのように処理されるかを比較します。エラーを発生させているシグネチャ検証を追跡し、その後、動作を一貫させ、reproducer が無効なシグネチャを報告しなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 55/100