False positive with strict_optional disabled just in submodule
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
The simplest example I got is the below setup, which I also attach here for convenience.
Directory structure:
.
├── my_subdir
│ ├── dog.py
│ └── __init__.py
├── pyproject.toml
└── repro.py
and the files are:
[tool.poetry.dependencies]
python = "^3.11.2"
[tool.poetry.dev-dependencies]
mypy = "1.5.1"
[tool.mypy]
strict_optional = true
[[tool.mypy.overrides]]
module = "my_subdir.*"
strict_optional = false
# dog.py
from dataclasses import dataclass
@dataclass
class Dog:
height: float | None
# repro.py
from my_subdir.dog import Dog
height: float | None = 1.0
Dog(height)
Now, enter command: mypy repro.py.
Expected Behavior
No errors
Actual Behavior
repro.py:4: error: Argument 1 to "Dog" has incompatible type "float | None"; expected "float" [arg-type]
Your Environment
- Mypy version used: 1.5.1
- Mypy command-line flags: _none)
- Python version used: 3.11.4
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit der Ausführung von mypy repro.py mit der angegebenen Einrichtung aus pyproject.toml, my_subdir/dog.py und repro.py. Verfolgen Sie, wie die Einstellung tool.mypy.overrides für my_subdir.* beim Überprüfen des importierten Dog-Konstruktors angewendet wird. Fertig ist die Aufgabe, wenn der Befehl keinen incompatible-type-Fehler für das nullable height-Argument meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 45/100