typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

networkx: Update usages of `SupportsGetItem` that should be more restrictive

Open Avasam opened this issue 2 months ago • 4 comments

Checked against the implementation to see when SupportsGetItem wasn't enough.

Will also reduce changes from #14038

CC @darabos since you added most of these in #13458 . Feel free to re-validate against the implementation.

Avasam avatar Sep 26 '25 16:09 Avasam

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Sep 26 '25 17:09 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Nov 02 '25 23:11 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Nov 03 '25 04:11 github-actions[bot]

I'm not a fan of replacing protocols with ABCs, especially if they're as broad as Mapping. Can't we use broader protocols?

srittau avatar Nov 14 '25 21:11 srittau

I can re-review usage. Mixing mapping-based protocols is quite annoying at the moment (without Protocol Intersection), and we may be getting too close to implementation details, where I'm not sure it's worth creating new (and/or combined) protocols just for this. But I'll see.

Avasam avatar Dec 18 '25 18:12 Avasam

My main beef with Mapping (and Sequence) is that it's not a protocol. Maybe it would make sense to add a MappingLike protocol to _typeshed that includes commonly used methods (like __getitem__, keys etc.).

srittau avatar Dec 18 '25 18:12 srittau

Thanks. And I think you meant https://github.com/python/typeshed/pull/15152

Avasam avatar Dec 20 '25 00:12 Avasam