Doesn't understand the attrs `default` and `converter` arguments correctly
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 20.6k
- Forks
- 3.3k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug Report
Mypy is complaining about incompatible assignment when it should not, because the default value assigned in the attr.ib() call will be passed to the converter (and be converted). But it seems that mypy do no currently understand that.
attrs docs about order of execution: https://www.attrs.org/en/stable/init.html#order-of-execution
To Reproduce
Code example
from pathlib import Path
import attr
@attr.s
class Options:
path: Path = attr.ib(default='.', converter=Path)
Expected Behavior
It should not trigger errors.
Actual Behavior
Triggers error: 6: error: Incompatible types in assignment (expression has type "str", variable has type "Path")
Your Environment
- Mypy version used: mypy 0.910
- Mypy command-line flags: Nothing special
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.8
- Operating system and version: MacOS catalina
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 mit dem bereitgestellten Python-Reproducer und der Dokumentation zur attrs-Ausführungsreihenfolge, und verfolge dann, wie mypy Standardwerte und Konverter von attr.ib() behandelt. Als erledigt gilt die Aufgabe, wenn das Beispiel keine inkompatible Zuweisung mehr meldet, während das bestehende attrs-Typverhalten korrekt bleibt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100