Semantic analyzer confuses a function with a module
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
The following code creates a package structure that demonstrates what I think is a bug in mypy's new semantic analyzer.
from os import makedirs
makedirs('src/core')
makedirs('src/stuff')
open('src/__init__.py', 'w').write("""
# nothing here
""")
open('src/core/__init__.py', 'w').write("""
from .run import config
""")
open('src/core/run.py', 'w').write("""
from ..stuff import somefunction
config = None
somefunction()
""")
open('src/stuff/__init__.py', 'w').write("""
from .somemore import more
from .somefunction import somefunction
""")
open('src/stuff/somefunction.py', 'w').write("""
def somefunction():
print("Hello, World!")
""")
open('src/stuff/somemore.py', 'w').write("""
def more():
from ..core import config
""")
When checking the created src package with mypy 0.720 and Python 3.7, I get the following error:
src/core/run.py:6: error: Module not callable
What mypy thinks is a module is actually a function. It just has the same name as its containing module.
When I check with --no-new-semantic-analyzer, I do not get this error.
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
Recrea el paquete src generado a partir del cuerpo de la incidencia y ejecuta mypy 0.720 con y sin --no-new-semantic-analyzer, centrándote en src/core/run.py y src/stuff/somefunction.py. Traza por qué somefunction se resuelve como un módulo en lugar de como una función invocable; se considera terminado cuando el nuevo analizador semántico acepta la llamada y el comportamiento está cubierto por una prueba de regresión.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- compilers
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100