Not finding type specifications in make_dataclass
Aperta
Nessuno ha ancora preso questa issue.
feature
priority-1-normal
topic-dataclasses
- Lingua principale
- Python
- Stelle
- 20.6k
- Fork
- 3.3k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Given the following script:
from typing import NamedTuple
from dataclasses import make_dataclass, dataclass
Emp1 = NamedTuple('Emp1', [('name', str), ('id', int)])
r1 = Emp1('raymond', 'xyz')
Emp2 = make_dataclass('Emp2', [('name', str), ('id', int)])
r2 = Emp2('raymond', 'xyz')
class Emp3(NamedTuple):
name: str
id: int
r3 = Emp3('raymond', 'xyz')
@dataclass
class Emp4:
name: str
id: int
r4 = Emp4('raymond', 'xyz')
mypy only finds three of the four type errors:
$ mypy --version
mypy 0.650
$ mypy nt_example.py
nt_example.py:5: error: Argument 2 to "Emp1" has incompatible type "str"; expected "int"
nt_example.py:14: error: Argument 2 to "Emp3" has incompatible type "str"; expected "int"
nt_example.py:21: error: Argument 2 to "Emp4" has incompatible type "str"; expected "int"
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproduci l'esempio con mypy 0.650, concentrandoti sulla chiamata a make_dataclass e sul costruttore che genera. Traccia il modo in cui mypy gestisce dataclasses.make_dataclass, quindi aggiungi un test di regressione basato sullo script; il lavoro è completato quando l'argomento stringa non valido per Emp2 viene segnalato insieme agli altri tre errori.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- devtools
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100