A configuration parse error names the line before the one at fault

Aperta Adatta ai principianti
#1,055 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à
1/5
Tempo stimato
1-3 ore
Idoneità per principianti
92/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend, testing

Direzione di ricerca

Leggi ploop in pybnf/parse.py, soprattutto i messaggi di errore e di log alle righe 1377 e 1383. Aggiungi test per una chiave sconosciuta e un valore formattato male che verifichino che la riga indicata corrisponda alla riga della chiave. L’issue è risolta quando entrambi i messaggi indicano il numero di riga corretto, a partire da uno.

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

Descrizione

bug minor

When PyBNF cannot parse a line of a configuration file, the error names the line before the one at fault.

To reproduce, save this as probe.conf and run pybnf -c probe.conf -o:

edition = 2
model = nope.bngl : nope.exp
job_type = fit
output_dir = out
max_iterations = many

PyBNF 1.8.2 (main at 292774b0) prints:

Error: Parsing configuration key 'max_iterations' on line 4.
max_iterations should be specified in the format 'max_iterations=x' where x is an integer

max_iterations is on line 5. An unknown key is reported the same way. A file with job_typ = fit on line 6 is reported as line 5. Comments and blank lines do not change the offset.

The cause is in ploop in pybnf/parse.py. It numbers the lines with enumerate(ls), which counts from 0. The error message at line 1377 and the log message at line 1383 print that index as it is. The fix is to print i + 1 in both, with a test that checks the reported line against the line the key is on, for an unknown key and for a badly formatted value.

The other errors that give a line number already count from 1. These are the constraint file parser in pybnf/constraint.py and the BNGL action check in pybnf/pset.py. No test pins the current number.

Found while drafting #1054.

Lingua principale
Python
Stelle
26
Fork
25
Merge medio
4h 9m
PR unite (30g)
11

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 lanl/PyBNF

Tutte le issue di lanl/PyBNF

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.