Skip to content

Wrongly assigned generics for networkx.Graph #14891

@lkct

Description

@lkct

In the current version of typeshed, networkx.Graph is defined as a generic type:

_Node = TypeVar("_Node", bound=Hashable)

class Graph(Collection[_Node]):

However, networkx.Graph is not a generic type at all:
https://github.com/networkx/networkx/blob/1660ac379a1c10e3d413760785dbc5cd2186a125/networkx/classes/graph.py#L71
and there'n no explicit __class_getitem__ in that class.

Therefore, when I use this type as hinted by the stubs, I get runtime error TypeError: type 'Graph' is not subscriptable.


I checked for similar issues, including #14389 and #12186, but none of them seem to address this problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions