Generic method returning nested class
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 54
Descripción
-
Are you reporting a bug, or opening a feature request? bug
-
Please insert below the code you are checking with mypy.
from typing import Generic, TypeVar T = TypeVar('T', bound='Base') class Base: class Inner: ... class A(Base): class Inner: ... class Foo(Generic[T]): def func(self) -> T.Inner: ... foo = Foo[A]() reveal_type(foo.func()) -
What is the actual behavior/output?
main.pyi:15: error: Revealed type is 'main.A*' -
What is the behavior/output you expect?
main.pyi:15: error: Revealed type is 'main.A.Inner*'If the analyzer is not sophisticated enough to figure this out yet, it should raise an error/warn and turn into
<nothing>rather than becoming the wrong type. -
What are the versions of mypy and Python you are using? mypy v0.701 + CPython v3.7.1
Do you see the same issue after installing mypy from Git master? yes, same results with 0.710+dev.bb7dbd5afd84656a62311e5f69a1cef6d06466bc
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
Comienza con el reproductor en main.pyi, especialmente con la anotación de retorno genérica de Foo.func y la llamada a reveal_type en la línea 15. Sigue cómo el comprobador de tipos resuelve T.Inner para Foo[A]; se considera terminado cuando informa de A.Inner en lugar de A, o emite un error y no produce ningún tipo.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- devtools
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 38/100