Better support for property-subclasses / read-only descriptors
オープン
まだ誰も着手していません。
feature
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
It seems mypy applies a bunch of special casing to @property that does not carry over when using a subclass of property or when defining a read-only descriptor.
https://mypy-play.net/?mypy=latest&python=3.12&gist=9a1c98026783a48c82f6a92e00acc941
from typing import Callable, ClassVar, Self, overload
class FooAbstract:
@property
def support(self) -> None: ...
class Foo(FooAbstract):
support: ClassVar[None] = None # ✅
# custom Property
class custom_property(property): ...
class BarAbstract:
@custom_property
def support(self) -> None: ...
class Bar(BarAbstract):
support: ClassVar[None] = None # ❌
# custom descriptor
class custom_getter[T, R]:
def __init__(self, fn: Callable[[T], R]) -> None:
self.fn = fn
@overload # type: ignore[no-overload-impl]
def __get__(self, instance: None, owner: type, /) -> Self: ...
@overload
def __get__(self, instance: T, owner: type | None = ..., /) -> R: ...
class BazAbstract:
@custom_getter
def support(self) -> None: ...
class Baz(BazAbstract):
support: ClassVar[None] = None # ❌
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リポジトリのファイルもテストも指定されていません。提供された mypy-play の再現例から始め、property のオーバーライドがどのように解析されるかを追跡してください。ClassVar によってオーバーライドされた場合に、property サブクラスと読み取り専用ディスクリプターの同等のケースが期待どおりに扱われれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100