Introduce Pydantic

Aperta
#177 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Read the dataclasses introduced before this issue and review the proposed follow-up in #172, then identify each dataclass import and its use. Check how Pydantic dataclasses behave with the project's existing types and tests; the issue defines done as replacing the standard dataclasses and gaining useful runtime type errors without affecting correctness.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement output refactor

I introduced dataclasses to replace Python dict in order to leverage more the static analyzer.

Now that they are in place (or even better, after #172) we could take one step more and make them pydantic.dataclasses.
They are designed as a drop-in replacement of standard library ones, and they perform a type check also at runtime, giving more helpful errors in case of issues.

Possible cons all stem from the consideration that "it is a further dependency, better one less than one more", but this consideration underlying motivations are mainly:

  • reliability, but pydantic is reliable, since it is used by big Python packages, and backed by known sponsors; so it might be not as reliable as NumPy, but reliable enough
  • extra complexity, but being a drop-in replacement, it should not require extra effort than usual dataclass, we just need to change imports

Another concern might be the performance deterioration, but we never use dataclasses in performance critical code (or Python constructs in general), so this really does not apply.
On the other hand, the code where dataclasses are used is really a complex part, so the benefit of improving runtime errors is possibly huge.

Runtime errors are not needed if we have static analysis always in place, but I am rather convinced that there are several occasions in which static analysis is not really performed (including during development).
In this respect, more about this in #178.

Lingua principale
Python
Stelle
13
Fork
9
Merge medio
6g 16h
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NNPDF/eko

Tutte le issue di NNPDF/eko

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.