`functools.partialmethod` loses return type and callable signature information
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
Start by reading the existing functools.partialmethod stub in typeshed and compare its descriptor behavior with the examples in the issue. Check the relevant stub tests for callable and descriptor typing; the issue does not name a test file. Done means preserving return-type and descriptor-binding information as far as current typing support allows, while acknowledging that a fully precise residual signature needs typing-spec support.
索引モデルが issue の本文から書いたものです。
説明
For code of this shape:
from functools import partialmethod
def pprint(arg: object, /, *, options: dict) -> str:
return "dummy"
class Foo: ...
class Bar: ...
Bar.__repr__ = partialmethod(pprint, options={})
it is difficult for type checkers to verify that partialmethod is compatible with the target method since it is currently typed with only a return-type parameter:
class partialmethod(Generic[_T]):
...
def __get__(self, obj: Any, cls: type[Any] | None = None) -> Callable[..., _T]: ...
The current stub does not preserve the wrapped callable’s parameters or receiver type, so type checkers cannot model these class and instance access forms even though this ebhaviour is valid at runtime, and partialmethod is a descriptor:
Bar.__repr__ # T: (self: Bar) -> str
Bar().__repr__ # T: () -> str
This forces Pyrefly and Pyright to reject this valid code. Mypy on the other hand, looks at stub’s descriptor fallback (Any) and infers partialmethod[Any] even when the wrapped callable returns str.
We should preserve descriptor binding and as much callable information as possible, while accepting that a fully precise residual signature needs typing-spec support.
Born from Pyrefly issue, https://github.com/facebook/pyrefly/issues/5138
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 2日 1時間
- マージ済み PR(30日)
- 115
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/typeshed のほかの issue
-
`networkx.set_edge_attributes` should support scalar value + name対応中かも @Fire162 が 10 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
false alarm on decode call対応中かも @jw9829 が 38 日前に担当しました。 オープンhelp wanted stubs: false positive
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
python/typeshed#16441 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Don't run pyright basic checks on projects with strict pyright settings in CI対応中かも @Mohith1612 が 74 日前に担当しました。 オープンproject: infrastructure
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python/typeshed#16005 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
stubs: improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python/typeshed#15548 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
stubs: improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
python/typeshed#15529 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
python/typeshed の issue をすべて見る
似ている issue
-
HandyModRTransform.deriv3 is wrong for m > 2対応中かも @SajalDevX が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
read_messages: the first read after subscribe/psubscribe returns no messages even when some are waiting対応中かも @matheussilvano が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
The-Swarm-Corporation/swarms-framework-docs#399 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
bump patch
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
autowarefoundation/autoware_carla_scenario#1321 ·
メンテナーはふだん 1 日以内に返信