precice / precice/python-bindings

Improve errors from `convert` function

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

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

enhancement
主要言語
Cython
スター
30
フォーク
19
PR マージ指標
30日以内にマージされた PR はありません

説明

The error return by the convert function is not helpful at the moment. I stumbled over this when I organized my participant names in an Enum

class ParticipantNames(Enum):
    MASS_LEFT = "Mass-Left"
    MASS_RIGHT = "Mass-Right"

One has to pass, for example, ParticipantNames.MASS_LEFT.value to the API. But I forgot the .values part, which led to an errors similar to

>>> precice.Interface(1,2,3,4)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cyprecice/cyprecice.pyx", line 87, in cyprecice.Interface.__cinit__
  File "cyprecice/cyprecice.pyx", line 24, in cyprecice.convert
TypeError: Could not convert.

I think it would be good to tell the user which type was received from the API and which types are supported here. If I would have known that I provided a <enum 'ParticipantNames'> instead of a <class 'str'> this would have helped me a lot debugging.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

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

調査の方向性

cyprecice/cyprecice.pyx の convert 関数(15-24 行目)から始め、文字列が想定されている箇所に Enum メンバーを渡して失敗を再現します。受け取った型とサポートされている型を示すようにエラーの挙動を更新し、その後、結果のメッセージを issue の Interface の例と照合します。

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

評価

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

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

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