python / python/typing

Wrapper/Proxy Generic Type

オープン
#802 コメント 14 件 リアクション 37 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

topic: feature
主要言語
Python
スター
1.8k
フォーク
302
平均マージ
23時間
マージ済み PR(30日)
8

説明

I've been putting some work into typeshed pull requests and I've noticed some places where I could really have used a Proxy Generic class - meaning I can inherit from Proxy[T] and that means that whatever attributes T has, Proxy[T] also has. We don't want to directly mark this as inheritance since then the distinction of a proxy is lost.

The examples I ran into are ProxyType and CallableProxyType in weakref or SynchronizedBase in multiprocessing,csharedtypes.
A big one would be unittest.Mock (See https://github.com/python/mypy/issues/1188).
I'm sure other cases exist,

Advantages:

  • Representing a proxy type easily
  • Allowing type checkers to enforce typing

Disadvantages:

  • Functions that get T won't accept Proxy[T] as an argument. Although the current state is probably something similar.

I'd really like to hear some opinions on the idea.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず提案とその議論を読み、weakref、multiprocessing.sharedctypes、unittest.Mock に関する例と、リンクされている mypy issue を確認してください。有意義な成果には、Proxy[T] を typing の設計に含めるべきかどうかについての合意と、その動作の明確な仕様が必要です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
tooling
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
静か
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。