bug: strict = true is incompatible with per-module configuration
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 20.6k
- Forks
- 3.3k
- Merge moyen
- 1 j 18 h
- PR mergées (30 j)
- 54
Description
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Reproduisez le problème avec les configurations mypy.ini et pyproject.toml indiquées, puis suivez le traitement des options strict et par module lors de l’exécution de mypy . C’est terminé lorsque strict s’applique à my_module.* tandis que tests.* accepte les définitions non typées dans les deux formats de configuration pris en charge.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 45/100