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

Abierto Apto para principiantes
#1,055 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
1/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
92/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
backend, testing

Línea de trabajo

Lee ploop en pybnf/parse.py, especialmente los mensajes de error y de registro en las líneas 1377 y 1383. Añade pruebas para una clave desconocida y un valor con formato incorrecto que verifiquen que la línea indicada coincide con la línea de la clave. El issue está resuelto cuando ambos mensajes indican el número de línea correcto, empezando por uno.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Python
Estrellas
26
Forks
25
Merge medio
4 h 9 min
PR fusionados (30 d)
11

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lanl/PyBNF

Todos los issues de lanl/PyBNF

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.