1.6.1 > 1.7.0 and 1.7.1 regression in for "broken" ``dataclasses``
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
When type checking the following code the output changes depending on whether you use 1.6.0 or 1.7.1.
To Reproduce
from dataclasses import dataclass
@dataclass(frozen=True)
class A:
attr_one: int
attr_two: int | None
@dataclass(frozen=True)
class B(A):
attr_two = None
instance = B(attr_one=1)
print(instance.attr_two)
Playground: https://mypy-play.net/?mypy=1.7.0&python=3.11&gist=f74740e7a7ef6bf0c9f88175a988aed5
The code is likely not doing what the author expects it to do, but the new message is wrong as attr_two can be referenced and is certainly not an instance of B.
Expected Behavior
main.py:15: error: Missing positional argument "attr_two" in call to "B" [call-arg]
Found 1 error in 1 file (checked 1 source file)
Actual Behavior
main.py:15: error: Missing positional argument "attr_two" in call to "B" [call-arg]
main.py:16: error: "B" not callable [operator]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
master branch on Playground.
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
Beginne damit, das Dataclass-Beispiel im Issue oder in der darin verlinkten mypy-playground-Konfiguration zu reproduzieren, und vergleiche die gemeldeten Diagnosen über die betroffenen Versionen hinweg. Verfolge die Dataclass-Verarbeitung, die die fehlerhafte Meldung "B not callable" erzeugt; abgeschlossen ist die Aufgabe, wenn das Beispiel erwartungsgemäß nur das fehlende Argument attr_two meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100