stubgen & pybind11: can we make them play nice(r)?
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
Bug Report
We're experimenting under https://github.com/pybind/pybind11/pull/4888 with a pybind11 behavior change, to generate
Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]
instead of a bare cpp_namespace::UserType.
It seems like mypy does handle outer-level Annotated, but not nested ones, e.g.
Iterator[str, Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]]
The results from stubgen (1.5.1, Google-internal toolchain) are like this:
def values(self, *args, **kwargs) -> Any: ...
Desired is:
def values(self) -> Iterator[str, Annotated[Any, CppTypePybind11("cpp_namespace::UserType")]]: ...
Does this ring any bells?
If you need more details, please let me know. (Note though that I don't know a lot about typing and mypy. This fell into my lap as Google-internal pybind11 owner & pybind11 maintainer on github.)
A more general question: What are your thought about changing the pybind11 behavior in this way? Is there a better way?
(A clear and concise description of what the bug is.)
To Reproduce
# Ideally, a small sample program that demonstrates the problem.
# Or even better, a reproducible playground link https://mypy-play.net/ (use the "Gist" button)
Expected Behavior
Actual Behavior
Your Environment
- Mypy version used: 1.5.1, Google-internal toolchain
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini(and other config files): - Python version used: 3.10
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
El informe menciona stubgen y muestra un ejemplo anidado de Annotated, pero no incluye archivos del repositorio ni pruebas. Empieza reproduciendo el comportamiento con el ejemplo mostrado de Python 3.10 y stubgen 1.5.1; después, sigue el punto en el que la firma se convierte en *args, **kwargs. El trabajo estará terminado cuando la salida generada conserve los tipos anidados Iterator y Annotated como en la firma deseada.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100