python / python/mypy

Wording in `mypy.plugin.Plugin.get_method[_signature]_hook` docstring

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

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

documentation needs discussion topic-plugins
主要言語
Python
スター
20.6k
フォーク
3.3k
PR マージ指標
PR 指標を取得中

説明

Documentation

The docstring of these plugin hook methods currently say:

https://github.com/python/mypy/blob/057508b4cb405fbc22e26b44f764b142352fcce5/mypy/plugin.py#L647-L648

...

https://github.com/python/mypy/blob/057508b4cb405fbc22e26b44f764b142352fcce5/mypy/plugin.py#L664

I understand this to mean that the argument to fullname will be "__main__.Base.method", because __main__.Base defines method.

However, this doesn't seem to be the case. Setting up the same example in the docstring:

  • mypy.ini
    [mypy]
    plugins = plugin.py
    files = test.py
    
  • plugin.py
    from mypy.plugin import Plugin
    
    def plugin(version):
        return TestPlugin
    
    class TestPlugin(Plugin):
        def get_method_signature_hook(self, fullname):
            if fullname.startswith("test."):
                print(f"Hook will be called with `{fullname}`")
    
  • test.py
    from typing import Any
    
    class Base:
        def method(self, arg: Any) -> Any: ...
    
    class Derived(Base): ...
    
    var: Derived
    var.method(42)
    
$ mypy
Hook will be called with `test.Derived.method`

I installed as far back as mypy 0.9x and it was the same behaviour as described above, displaying test.Derived.method (not test.Base.method).


Is there something wrong with the docstring (perhaps from outdated behaviour that no longer applies), or have I misunderstood something?

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

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

はじめの一歩

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

調査の方向性

まず、mypy/plugin.py の 647-648 行付近と 664 行にあるリンク先の hook docstring を確認し、続いて提示された mypy.ini、plugin.py、test.py の例を再現します。ドキュメントに記載された fullname と、観測された test.Derived.method の値を比較します。docstring が hook の引数を正確に説明するか、報告された誤解を明らかにできれば作業は完了です。

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

評価

技術スタック
python
領域
documentation
issue の種類
ドキュメント
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

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

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