Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Problem
I mistakenly supplied"blue\n"
as the argumentc
formatplotlib.axes.Axes.scatter
, thenmatplitlib
claimed for illegal color name like this:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not blue
I was not aware that the argument actually contained a trailing newline so I was very confused.
Proposed solution
The error message would be nicer if it outputs user's input viarepr
.
For example, in this case the error messagehere can be easily replced with:
raiseValueError(f"'c' argument must be a color, a sequence of colors, "f"or a sequence of numbers, not{c!r}")from
so that we may now get an easy-to-troubleshoot error like this:
ValueError: 'c' argument must be a color, a sequence of colors, or a sequence of numbers, not "blue\n"
This kind of improvement can be applied to many other places.