Plugin API feature requests
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
I recently wrote a plugin that used get_function_hook() to intercept instantiations of a certain set of classes (recognized by name), and found a bunch of functionality missing. Here's a list.
-
I needed the names of the arguments but they were not directly available. I ended up using
rtype.type.names['__init__'].node.arg_names(with various type andNoneguards) and subtracting 1 to compensate forself, which looked very hacky. It would be nice ifFunctionContextalso has anarg_namesargument. -
CheckerPluginInterfacehas nofail()method. It exists on the implementation, and the similarTypeAnalyzerPluginInterfacedoes define it. -
I needed to look up a name in the module's global namespace; I ended up calling
ctx.api.lookup_qualified()but that's not in the interface, and perhaps it's not the thing to use. -
I needed the functionality of
parse_bool()but it's not there (it only exists onSemanticAnalyzerPluginInterface). -
I needed something similar to what's in mypy/plugins/common.py as
_get_bool_argument()_get_argument()but had to write my own because the starting point was aFunctionContextinstead of aClassDefContext. -
(Not directly a plugin issue, but this happened.) I was also bitten by the error message
The type alias{} is invalid in runtime context-- this seems a bit inconsistent because expanding theUnionthat the alias references makes it go away. I.e. ifA = Optional[int],foo(A)gives that error, butfoo(Optional[int])doesn't.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Revisa las interfaces de plugins relacionadas con FunctionContext, CheckerPluginInterface y SemanticAnalyzerPluginInterface, junto con mypy/plugins/common.py y el comportamiento reportado de los alias de tipos en tiempo de ejecución. El issue contiene varias solicitudes de API independientes en lugar de un único cambio delimitado; para completarlo habría que decidir qué solicitudes son compatibles y definir su comportamiento esperado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100