Title: [networkx] Some functions don't accept valid Graph types · Issue #16365 · python/typeshed · GitHub
Open Graph Title: [networkx] Some functions don't accept valid Graph types · Issue #16365 · python/typeshed
X Title: [networkx] Some functions don't accept valid Graph types · Issue #16365 · python/typeshed
Description: I'm using networkx with the Generics introduced by and think I have found a bug. For some context: I'm trying to run a type checker on a class Foo that looks like so: class Bar(Mapping[str, Any]): ... class Foo(Graph[int, Bar]): node_att...
Open Graph Description: I'm using networkx with the Generics introduced by and think I have found a bug. For some context: I'm trying to run a type checker on a class Foo that looks like so: class Bar(Mapping[str, Any]): ...
X Description: I'm using networkx with the Generics introduced by and think I have found a bug. For some context: I'm trying to run a type checker on a class Foo that looks like so: class Bar(Mapping[str,...
Opengraph URL: https://github.com/python/typeshed/issues/16365
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[networkx] Some functions don't accept valid Graph types","articleBody":"I'm using networkx with the Generics introduced by and think I have found a bug.\n\nFor some context:\nI'm trying to run a type checker on a class Foo that looks like so:\n```python\nclass Bar(Mapping[str, Any]):\n ...\n\nclass Foo(Graph[int, Bar]):\n node_attr_dict_factory = Bar\n ...\n```\nThe key point being that `Bar` implements `Mapping`, but is **not** a `dict`.\n\n`networkx.draw(G: Graph[Node_], ...)` doesn't accept this Foo graph, and gives a typing error with the current stubs.\n\n\nIn the transition to generic types for node and edge data, `_NodeData` and `_EdgeData` were given an upper bound of `Mapping[str, Any]` and a default of `dict[str, Any]`. (https://github.com/python/typeshed/pull/15660/changes)\n\nWith this, most functions that took a `Graph[_Node]` parameter before, were changed to take a `Graph[_Node, _NodeData, _EdgeData]`\n\nHowever, some weren't changed, which means they effectively have a parameter with type: `Graph[_Node, dict[str, Any], dict[str, Any]`.\nPassing a `Graph[_Node, Mapping[str, Any], dict[str, Any]]` causes a type error.\n\nIs there a reason that some functions weren't updated to use `Graph[_Node, _NodeData, _EdgeData]` @ThePiep ?\nI see that there are a few other functions in the library that use `Graph[_Node]` still, but am unsure why.\n","author":{"url":"https://github.com/jonwinfrey-riverlane","@type":"Person","name":"jonwinfrey-riverlane"},"datePublished":"2026-09-08T09:35:26Z","url":"https://github.com/python/typeshed/issues/16365"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:4a3e561d-71f2-6160-150a-1b2b1cf7b61e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8676:2ED7C5:109B41D:1726CCB:6B06B7FA |
| html-safe-nonce | e9e8fbea5f309a140691857945656ba48de5ed1a8ca63da65d3b77a45cb793f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4Njc2OjJFRDdDNToxMDlCNDFEOjE3MjZDQ0I6NkIwNkI3RkEiLCJ2aXNpdG9yX2lkIjoiMjM0MTQwNjg5NDk5ODMzNzUzMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 844771e0193ebb33acd9ea6d977679364ae3438fe55d2e9a8a985b32e78f77dd |
| hovercard-subject-tag | issue:5384977547 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/16365/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5dbbb44fff1108f5cda08d2e7dc01f16641a392f2607fd8cb023da7bfee51968/python/typeshed/issues/16365 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5dbbb44fff1108f5cda08d2e7dc01f16641a392f2607fd8cb023da7bfee51968/python/typeshed/issues/16365 |
| og:image:alt | I'm using networkx with the Generics introduced by and think I have found a bug. For some context: I'm trying to run a type checker on a class Foo that looks like so: class Bar(Mapping[str, Any]): ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jonwinfrey-riverlane |
| hostname | github.com |
| expected-hostname | github.com |
| None | 32031aaff792fa7ad778f7418e1fbfc0d525a5779804329b769aa75230448a18 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 37014d914b7d14eede971655595f687a0202af40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width