Better error message for overloading functions that return union type #2020
Labels
enhancement
New feature or request
fixed in next version (main)
A fix has been implemented and will appear in an upcoming version
Networkx, a popular library for working with graph, uses lots of overloading. One example is iterating through edges in the graph. It can returns an iterator of tuples of 3 or 4 items (if
keys
argument is true). For example:The error message is quite confusing because at first it told me to use a tuple of 4, but then when I use tuple of 4, it told me to use a tuple of 3. It would be better if the error message could mention the union type so the developers know that they need to do type narrowing or use type guard.
The text was updated successfully, but these errors were encountered: