precice / precice/python-bindings
Improve errors from `convert` function
Nessuno ha ancora preso questa issue.
- Lingua principale
- Cython
- Stelle
- 30
- Fork
- 19
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia in cyprecice/cyprecice.pyx, nella funzione convert, alle righe 15-24, e riproduci il fallimento passando un membro di Enum quando è prevista una stringa. Aggiorna il comportamento dell’errore in modo che identifichi il tipo ricevuto e i tipi supportati, quindi verifica il messaggio risultante rispetto all’esempio Interface nell’issue.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- api
- Tipo di issue
- Bug
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Stato di attività
- Attiva
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 78/100