flaxandteal / dewret

DEclarative Workflow REndering Tool
Apache License 2.0
1 stars 0 forks source link

Better error messages [1-40,41] #9

Open philtweir opened 4 months ago

philtweir commented 4 months ago

id: 1-39], [MAJOR]: Executing the example fails with the error message

File "C:\Users\...dewret\src\dewret\workflow.py", line 322,
in add_step
raise TypeError(f"All tasks should have a type annotation.")
TypeError: All tasks should have a type annotation.
That's because increment misses a return type.

[id: 1-40], [MAJOR]: The initial error stack does not contain the line of the task causing the error (at least I didn't see it). Instead, it guides to a (from the user's perspective) non-existing line ("line 322"). For the given example, this is not a big issue/easy to spot, of course. But in general this is an issue.

[id: 1-41], [MODERATE], [ENH]: The initial error message is fine, however, maybe a more precise hint and/or more information would be nice. For example/some proposals:

  1. The error message could contain the task name (and module), i.e. for example TypeError: Task 'increment' misses complete type annotation.
  2. The error message could be more precise with respect what type annotation misses, i.e. for example: TypeError: Task 'increment' misses type annotations for: 'return type', parameter 'foo', 'parameter bar'.
  3. The error message could (in addition) give a proper example:
    `TypeError: Task 'increment' has no or incomplete type annotations.
    Example for a valid task:
    @task()
    def add_one(num: int) -> int:
    return num + 1