Type checking for *args and **kwargs when passing them to another function
まだ誰も着手していません。
評価
調査の方向性
まず issue 内の wrapper と inner-function の例を確認し、次に既存の提案と制約について述べた、リンク先の mypy#19302 の議論を読んでください。*args と **kwargs を受け取る関数またはコンストラクターから wrapper の引数型を導出または宣言するための、文書化され合意されたアプローチができれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Problem:
I am writing a python application, and I made a function that creates an object and passes its additional *args and **kwargs to object's constructor and takes few its own arguments. I want to make *args and **kwargs typed exactly as inner function's arguments.
Description and examples:
A simple example with two functions:
def inner(a: int, b: int) -> None:
...
def wrapper(arg1: str, *args, **kwargs) -> None:
inner(*args, **kwargs) # It will automatically detect passing arguments to another function
In my case, inner is object constructor, I gave an example with functions to make it more simple.
Type checkers should see wrapper's signature like this:
def wrapper(arg1: str, a: int, b: int):
...
It may be enabled by default when passing *args and **kwargs to another function is detected or it may be enabled by adding a decorator to the function.
Detailed description:
Already suggested this to mypy, detailed description of this feature can be found here: python/mypy#19302.
- 主要言語
- Python
- スター
- 1.8k
- フォーク
- 302
- 平均マージ
- 23時間
- マージ済み PR(30日)
- 8
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/typing のほかの issue
-
topic: typing spec
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
topic: typing spec
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
topic: documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
topic: documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
-
topic: conformance tests topic: typing spec
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
似ている issue
-
Add: hunch オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
DiamondLightSource/dodal#2211 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
openml/openml-python#1749 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
sipyourdrink-ltd/bernstein#6191 ·