-
Notifications
You must be signed in to change notification settings - Fork 970
Closed
Labels
enhancementNew feature or requestNew feature or requestfixed in next version (main)A fix has been implemented and will appear in an upcoming versionA fix has been implemented and will appear in an upcoming version
Description
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:
g = nx.MultiDiGraph()
...
# pylance complains that: Tuple size mismatch: expected 3 but received 4
for uid, vid, edge_data in g.edges(data=True):
pass
# pylance compalins that: Tuple size mismatch: expected 4 but received 3
for uid, vid, eid, edge_data in g.edges(data=True, keys=True):
pass
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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfixed in next version (main)A fix has been implemented and will appear in an upcoming versionA fix has been implemented and will appear in an upcoming version