Skip to content

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

Closed

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

Activity

  1. brianschubert commented on Aug 21, 2025

    @brianschubert
    Collaborator

    Thanks for the report!

    I think this may already be addressed in #14597, cc @Avasam

  2. added
    stubs: false positive
    on Aug 21, 2025
  3. melisande-c commented on Aug 21, 2025

    @melisande-c
    Author

    Oh so it is! Sorry I didn't see that

  4. added
    priority: regression
    on Aug 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: regressionstubs: false positive

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions