python / python/mypy

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

Abierto
#19,181 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

documentation needs discussion topic-plugins
Lenguaje dominante
Python
Estrellas
20.6k
Forks
3.3k
Merge medio
1 d 18 h
PR fusionados (30 d)
54

Descripción

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?

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con los docstrings de los hooks enlazados en mypy/plugin.py alrededor de las líneas 647-648 y 664, y después reproduce el ejemplo proporcionado de mypy.ini, plugin.py y test.py. Compara el fullname documentado con el valor observado test.Derived.method; el trabajo estará terminado cuando el docstring explique correctamente el argumento del hook o aclare el malentendido señalado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
documentation
Tipo de issue
Documentación
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
48/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.