Passing wrong number of arguments to generic produces runtime errors
オープン
まだ誰も着手していません。
stdlib
topic-typing
type-feature
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
In pypa/hatch#2437, we see a change to a generic type, adding an extra parameter, causing a run-time failure, and since this was used in a build plugin, it cause a build failure and my package to fail to install.
pdm.exceptions.BuildError: Build backend raised error: Showing the last 10 lines of the build output:
class GitInfoBuildHook(BuildHookInterface[Any]):
~~~~~~~~~~~~~~~~~~^^^^^
File "/usr/lib/python3.12/typing.py", line 398, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/typing.py", line 1083, in _generic_class_getitem
_check_generic(cls, params, len(cls.__parameters__))
File "/tmp/pdm-build-env-4xoutxun-shared/lib/python3.12/site-packages/typing_extensions.py", line 3274, in _check_generic
raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments"
TypeError: Too few arguments for <class 'hatchling.builders.hooks.plugin.interface.BuildHookInterface'>; actual 1, expected at least 2
I find this behavior fairly surprising; I would only expect type errors in an annotation to cause errors when doing typechecking, not runtime errors like this.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、トレースバックに示されている typing.py のパスを通じて、報告されたジェネリックパラメーターの失敗を再現し、次に typing_extensions.py の対応する検証と比較します。ジェネリック引数の数が正しくない場合の意図された動作が確立され、正しい runtime typing の使用を壊すことなく回帰テストでカバーされれば、この問題は解決です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 活発
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100