Skip to content

networkx: DiDegreeView doesn't have overload for single node as argument to __call__ #14616

@melisande-c

Description

@melisande-c

Hi,

Since the recent release of types-networkx 3.5.0.20250821, Pyright is giving errors when trying to call DiGraph.in_degrees and DiGraph.out_degrees for a single node. This is a valid way to access the data as described in the networkx docstings below:

https://github.com/networkx/networkx/blob/c5f46466d7f27fd16e4f3b59a44c0b9cca443caf/networkx/classes/digraph.py#L1133-L1141.

To reproduce the error

>>> import networkx as nx

>>> G = nx.DiGraph()
>>> G.add_edge(1, 3)
>>> G.add_edge(2, 3)
>>> G.add_edge(3, 4)
>>> G.add_edge(3, 5)
>>> G.add_edge(3, 6)

>>> print((G.in_degree(3), G.out_degree(3)))
(2, 3)

And the Pyright error is

temp.py
  temp.py:10:8 - error: No overloads for "__call__" match the provided arguments (reportCallIssue)
  temp.py:10:20 - error: Argument of type "Literal[3]" cannot be assigned to parameter "nbunch" of type "Iterable[Unknown] | None" in function "__call__"
    Type "Literal[3]" is not assignable to type "Iterable[Unknown] | None"
      "Literal[3]" is not assignable to "None"
      "Literal[3]" is incompatible with protocol "Iterable[Unknown]"
        "__iter__" is not present (reportArgumentType)
  temp.py:10:24 - error: No overloads for "__call__" match the provided arguments (reportCallIssue)
  temp.py:10:37 - error: Argument of type "Literal[3]" cannot be assigned to parameter "nbunch" of type "Iterable[Unknown] | None" in function "__call__"
    Type "Literal[3]" is not assignable to type "Iterable[Unknown] | None"
      "Literal[3]" is not assignable to "None"
      "Literal[3]" is incompatible with protocol "Iterable[Unknown]"
        "__iter__" is not present (reportArgumentType)
4 errors, 0 warnings, 0 informations

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: regressionSomething that worked before doesn't work anymorestubs: false positiveType checkers report false errors

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions