Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
bzoracler opened this issue May 31, 2025 · 0 comments
Open

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

bzoracler opened this issue May 31, 2025 · 0 comments

Comments

@bzoracler
Copy link
Contributor

bzoracler commented May 31, 2025

Documentation

The docstring of these plugin hook methods currently say:

mypy/mypy/plugin.py

Lines 647 to 648 in 057508b

class instantiation). This function is called with the method full name using
the class where it was _defined_. For example, in this code:

...

this method is called with '__main__.Base.method', and then with

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant