python / python/mypy

Running `get_dynamic_class_hook()` after `get_class_decorator_hook_2()`

オープン
#12,864 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

feature
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Feature

It would be useful to run get_dynamic_class_hook() from plugins after get_class_decorator_hook_2() to support dynamic classes that inspect existing dataclasses / attrs classes.

Pitch

We have an internal mypy plugin that makes "partial" classes, where all required attributes are optional. It does this by examining the __init__ of an attrs class and creating a new __init__ for the new class where all args are now optional. This works in mypy 0.942, occasionally crashes in 0.950, and doesn't work at all in 0.960 (128661ccbf4396ed1538421c481f1773c7490169) because the attrs __init__ is not present during get_dynamic_class_hook().

Is there some way to work around this?

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

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

はじめの一歩

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

調査の方向性

まず、プラグインのエントリポイントである get_dynamic_class_hook() と get_class_decorator_hook_2() をたどり、フックの順序によって attrs が生成した init メソッドがどのように公開されるかを確認します。動的クラスフックがデコレータ処理後の既存の dataclasses または attrs クラスを検査でき、ここで説明されている partial-class プラグインのシナリオに対する回帰テストのカバレッジが追加されたら、この変更は完了です。

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

評価

技術スタック
python
領域
compilers
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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