Inconsistent dataclass declaration
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 1日 19時間
- マージ済み PR(30日)
- 82
説明
The dataclass decorator in the typeshed package has an inconsistency in its overloads. Specifically, when cls is passed explicitly as None, it is unclear whether additional arguments (e.g., init, repr, etc.) should be allowed or not. The current implementation allows passing cls=None alongside additional arguments, but this usage is not explicitly documented or validated.
Expected Behavior
The overloads should clearly define and document the behavior of cls=None when additional arguments are provided:
If allowed, the typing should reflect that explicitly.
If not allowed, the implementation should prevent or warn against such usage.
Current Behavior
Passing cls=None with arguments like kw_only=True is allowed, but this behavior is not described in the overloads. For example:
decorator = dataclass(None, kw_only=True)
@decorator
class MyClass:
x: int
The above works but is ambiguous in terms of type checking and intended usage.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、typeshed パッケージ内の dataclass デコレーターのオーバーロードを見つけ、示されている dataclass(None, kw_only=True) の例と比較します。追加の引数を伴う cls=None がサポートされているかを明確にし、そのうえでオーバーロードとドキュメントがその判断を一貫して表すようにします。型チェッカーとユーザーにとって動作が明確になれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100