python / cpython

The Python programming language
https://www.python.org
Other
63.41k stars 30.37k forks source link

Argument Clinic: make error messages more helpful to developers #115077

Open erlend-aasland opened 9 months ago

erlend-aasland commented 9 months ago

Some[^1] of the Argument Clinic error messages only point to the problem in the clinic input, but do not suggest how to fix it. Suggesting to do an audit of clinic.py and improve the error messages that are too implicit or provide too little information/context to the developer.

Random selection of error messages that might be improved:

(There might be better examples; this was the result of a very quick and short audit.)

cc. @sobolevn

[^1]: but, definitely not all!

Linked PRs

erlend-aasland commented 9 months ago

Suggested by @sobolevn in https://github.com/python/cpython/pull/114930#discussion_r1477665089.

sobolevn commented 9 months ago

What do you think: is it better to work on this one-by-one or in bulk?

erlend-aasland commented 9 months ago

There's also the possibility of always including the offending line, thus making these error messages look more like tracebacks:

Error in file 'test.c' on line 2:
    fn:
    ^
Illegal function name.
erlend-aasland commented 9 months ago

What do you think: is it better to work on this one-by-one or in bulk?

One-by-one is too fine-grained, IMO; I think batches are fine. For example, all the converters in one PR and all the return converters in another.

serhiy-storchaka commented 9 months ago

I would try to do this in one piece. It may expose some patterns and lead to better structure of the code and tests.

But is some cases cannot be easily improved, I would left them out. And if some cases require significant rewriting, they can be split in a separate PR. You cannot say if this is needed before you try.

erlend-aasland commented 9 months ago

+1, @serhiy-storchaka. BTW, feel free to contribute to my draft PR, if you wish.