mypy does not show error in excluded folder when PYTHONPATH set
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Comienza con la estructura de paquete reproducida que contiene excluded_folder/excluded.py e included_folder/included.py, y después compara los dos comandos de mypy con y sin PYTHONPATH=. Traza cómo se descubren --exclude y los módulos importados. Se considera terminado cuando la invocación con PYTHONPATH=. informa del valor de retorno incompatible en excluded.py, con una prueba de regresión que cubra ambos comandos.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Bug Report
As far as I understand, when I use the exclude setting for some folder mypy should still show errors in these packages when imported, because of the follow imports logic. However, if I set the PYTHONPATH to the current working directory, it does not show these errors anymore.
To Reproduce
Here is the folder structure:
src/
|--excluded_folder/
| |-- excluded.py
| |-- __init__.py
|--included_folder/
|-- included.py
|-- __init__.py
The contents of the file excluded.py are as follows:
def function() -> str: # obviously wrong return type
return 5
File included.py looks like so:
from excluded_folder.excluded import function
print(function)
Now, if i run mypy like so, with the setting to exclude the excluded folder, it reports this:
$ mypy --strict --exclude excluded_folder src
src/excluded_folder/excluded.py:3: error: Incompatible return value type (got "int", expected "str") [return-value]
Found 1 error in 1 file (checked 2 source files)
This is what i would expect. It still shows the errors in the file, although excluded.
But if i run mypy with PYTHONPATH set to the current working directory, it does not show any error anymore:
% PYTHONPATH=. mypy --strict --exclude excluded_folder src
Success: no issues found in 2 source files
Expected Behavior
Mypy should also show the errors when the PYTHONPATH is set.
Actual Behavior
Mypy does not show the errors when the PYTHONPATH is set.
Your Environment
- Mypy version used:
mypy 1.8.0 (compiled: yes) - Mypy command-line flags: see commands above
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: Python 3.11.3
- Lenguaje dominante
- Python
- Estrellas
- 20.6k
- Forks
- 3.3k
- Merge medio
- 1 d 18 h
- PR fusionados (30 d)
- 54
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.
Más de python/mypy
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
bug topic-configuration topic-error-reporting
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Todos los issues de python/mypy
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
bancolombia/sentinel#23 ·
-
test md AbiertoCI
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100