(🐞) incompatible `Callable`s are incorrectly joined into `builtins.function`
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
from typing import Callable, _T as T
from types import FunctionType
class C:
def __init__(self, i: int=1): ...
def join(t1: T, t2: T) -> T: ...
c1: Callable[[], object] = C
c2: Callable[[int], object] = C
result = join(c1, c2)
reveal_type(result) # Revealed type is "builtins.function"
print(isinstance(result, FunctionType) # False
this is not an instance of builtins.function, it is a type[C]. it should be joined into a union, or something else, either object or Callable[..., object] or something
the same defect is observed with a non-function callable instance:
class C:
def __call__(self, i: int = 1): ...
- reraised from #17017 as it wasn't resolved
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された mypy の再現コードを実行し、明らかになった型と実行時の値を比較します。builtins.function を生成する原因となっている callable の結合と型推論の経路を追跡し、互換性のない callable 型に対する意図した結果を確定したうえで、クラスの例と callable インスタンスの例の両方に対するカバレッジを追加します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100