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

オープン 初心者向け
#1,055 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
1/5
見積もり時間
1〜3時間
初心者へのやさしさ
92/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
backend, testing

調査の方向性

pybnf/parse.py の ploop を読み、特に 1377 行目と 1383 行目のエラーメッセージとログメッセージを確認してください。不明なキーと形式が不正な値のテストを追加し、報告される行がキーの行と一致することを検証してください。両方のメッセージが正しい 1 始まりの行番号を報告すれば、issue は修正済みです。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Python
スター
26
フォーク
25
平均マージ
4時間 9分
マージ済み PR(30日)
11

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

lanl/PyBNF のほかの issue

lanl/PyBNF の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。