bug: strict = true is incompatible with per-module configuration
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 45/100
Línea de trabajo
Reproduce el problema con las configuraciones de mypy.ini y pyproject.toml mostradas y, a continuación, rastrea cómo se procesan las opciones strict y por módulo al ejecutar mypy . Se considera terminado cuando strict se aplica a my_module.* mientras tests.* acepta definiciones sin tipar en ambos formatos de configuración compatibles.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
To Reproduce
Create the following file structure:
my_module/__init__.py
tests/__init__.py
mypy.ini
Both my_module/__init__.py and tests/__init__.py contain:
def untyped():
...
Which should trigger an error when run with strict but otherwise pass.
In mypy.ini:
[mypy]
strict = true
[mypy-tests.*]
strict = false
That is, I want strict mode in my source code but not my tests.
Then I run this using mypy .
Expected Behavior
I expect to get an error for my source code but not my tests:
my_module/__init__.py:1: error: Function is missing a return type annotation
my_module/__init__.py:1: note: Use "-> None" if function does not return a value
Actual Behavior
I get an error for both my source code and tests.
It seems like strict = False in the per module section is ignored.
tests/__init__.py:1: error: Function is missing a return type annotation
tests/__init__.py:1: note: Use "-> None" if function does not return a value
my_module/__init__.py:1: error: Function is missing a return type annotation
my_module/__init__.py:1: note: Use "-> None" if function does not return a value
If I add an explicit allow_untyped_defs = True to the mypy-tests.* section:
[mypy]
strict = true
[mypy-tests.*]
strict = false
allow_untyped_defs = True
That seems to be processed fine (I now get no errors for my tests but still get errors for my source).
So I believe the config file is valid, mypy is picking up that the options only apply to tests.*.
I also tried flipping the enable/disable:
[mypy]
strict = false
[mypy-my_module.*]
strict = true
But I get the same result.
This also seems to be the case with pyproject.toml configs.
- 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 1/5 Menos de una hora Aptitud para principiantes 90/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
zostera/django-bootstrap4#894 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
use-agent-os/agent-os#3276 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
NousResearch/hermes-agent#117848 ·