function is lacking a `__signature__` attribute
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
stdlib/builtins.pyi の 1009 行目付近から始め、function class がどのように宣言されているかを確認します。signature に対して要求されているオプションのサポートを、PEP 362 および提供された代入例と比較し、そのうえで、stub の変更が完了したときに pyright などの型チェッカーがそれを受け入れることを確認します。
索引モデルが issue の本文から書いたものです。
説明
PEP-362 specifies that in order to cache the signature of any function, it is possible for the user to set its __signature__ attribute.
Actual
This attribute is not set in the builtins module over at https://github.com/python/typeshed/blob/main/stdlib/builtins.pyi#L1009
As a result a typechecker might reject the following piece of code
from inspect import signature
def main():
def f():
pass
f.__signature__ = signature(f)
if __name__ == "__main__":
main()
e.g. with pyright I have a false positive
/Users/leogermond/Lab/python/signature/main.py
/Users/leogermond/Lab/python/signature/main.py:9:7 - error: Cannot assign to attribute "__signature__" for class "function"
Attribute "__signature__" is unknown (reportFunctionMemberAccess)
1 error, 0 warnings, 0 informations
Expected
I would the __signature__ attribute to be specified in the function class (with a special marker indicating it's optional?) of the builtins module. A type checker such as pyright could then infer that setting this attribute is possible and accept the piece of code given in example.
- 主要言語
- Python
- スター
- 5.1k
- フォーク
- 2.1k
- 平均マージ
- 2日 7分
- マージ済み PR(30日)
- 116
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/typeshed のほかの issue
-
`networkx.set_edge_attributes` should support scalar value + name対応中かも @Fire162 が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 1 日以内に返信
-
false alarm on decode call対応中かも @jw9829 が 36 日前に担当しました。 オープンhelp wanted stubs: false positive
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
python/typeshed#16441 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Don't run pyright basic checks on projects with strict pyright settings in CI対応中かも @Mohith1612 が 73 日前に担当しました。 オープンproject: infrastructure
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python/typeshed#16005 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
stubs: improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
python/typeshed#15548 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
-
stubs: improvement
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
python/typeshed#15529 · コメント 5 件 ·
メンテナーはふだん 1 日以内に返信
python/typeshed の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
elviskahoro/sdk-python-attio#144 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信
-
RenyiELBO raises TypeError when model has no sample sites対応中かも @alibb007 が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Four evaluation scripts unpack init_memmachine_params's five return values into three namesオープン
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
MemMachine/MemMachine#1911 ·
メンテナーはふだん 3 日以内に返信