Cannot suppress python_version-related errors in third-party code
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
If i have python_version = 3.5 set, it's not possible to tell mypy to ignore related syntax errors it finds in dependencies.
Use case: i have code which needs to support python 3.5, as well as newer versions. I run mypy against it under various versions of python, with python_version = 3.5 set so that i don't accidentally introduce something which is incompatible (like variable annotations) which might not get caught until later. This has worked fine until some of the dependencies have started using variable annotations.
To Reproduce
- Create a venv using python 3.6+.
pip install mypy importlib-metadata# Using importlib-metadata as an example lib which uses variable annotations- Create
setup.cfgwith:
[mypy]
python_version = 3.5
[mypy-importlib_metadata]
ignore_errors = True
- Create
test.pywith:
import importlib_metadata
- Run
mypy test.py
Expected Behavior
mypy should enforce python_version = 3.5 for test.py, but it should ignore any version-related issues in importlib_metadata.
Actual Behavior
mypy fails with:
venv/lib/python3.8/site-packages/importlib_metadata/__init__.py:88: error: Variable annotation syntax is only supported in Python 3.6 and greater
Found 1 error in 1 file (errors prevented further checking)
mypy doesn't seem to treat this as a 'fatal' error, either, as setting pdb = True has no effect.
Your Environment
- mypy 0.790 and 0.800
- python 3.6.7, 3.6.12 and 3.8.5
- Debian Stretch and Linux Mint 20.1 (Equivalent to Ubuntu 20.04)
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
Empieza reproduciendo la configuración de setup.cfg con python_version = 3.5, la dependencia importlib_metadata, test.py y mypy test.py. Rastrea cómo mypy gestiona los errores de sintaxis relacionados con la versión procedentes de las dependencias importadas; se considera terminado cuando test.py sigue imponiendo Python 3.5 mientras los errores relacionados con la versión de la dependencia se suprimen mediante ignore_errors.
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
- Bien especificado
- Aptitud para principiantes
- 35/100