[ty] bump dependencies to pull in Salsa support for ordermap#21854
[ty] bump dependencies to pull in Salsa support for ordermap#21854oconnor663 merged 1 commit intomainfrom
ordermap#21854Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
I don't think we should use OrderedMap or Set everywhere
But I might be missing something here. What's the reason why we should use OrderedMap? |
|
|
|
@MichaReiser I think you might be quiet reasonably assuming this is a bigger change than it is OrderMap and IndexMap are nearly identical types, both being "HashMap but iteration order is insertion order" (i.e. neither is BTreeMap-like) I think the only difference that exists between them is:
|
|
Ah right. Order not ordered. Do we need the more strict definition of ordermap (that they're only equal if they have the same elements in the exact same order)? Like I could see this hurt fixpoint convergence. |
The most important practical difference is this part above: "Using the order...allows ordermap to implement PartialOrd, Ord, and Hash".
Ah that's a good point. Apart from seeing that tests pass, I'm not sure. |
We need OrderMaps/OrderSets whenever we need to use an insertion-order-preserving map/set as a field of a salsa-interned struct. Because fields of salsa-interned structs must be hashable, and IndexMaps/IndexSets are not hashable. There are therefore many places in ty where we already use OrderMap/OrderSet. This PR switches all the other bits of the ty codebase, that don't strictly need to be OrderMaps/OrderSets, over to using those structs instead of IndexMaps/IndexSets. I believe the rationale is that we have OrderMap as a dependency anyway, and it lowers the cognitive burden on us as developers if we no longer have to worry every time we write a salsa-interned struct whether a field should be an OrderMap/OrderSet or an IndexMap/IndexSet. |
|
|
(Since there's only a single usage of |
|
Thanks for the additional context. I'm still not sure this justifies the stricter equality everywhere but I'm probably missing some context. Only having to know one map type (as I'm a perfect example of), certainly makes live easier
I don't think you have to worry: it always must be an orderedset |
Yes, bad wording on my part :-) but you do have to think twice in contexts outside of salsa-interned struct fields currently. I'm very neutral on this FWIW — I do agree that it would make life a bit easier, but I don't really have a strong opinion any way at all! |
|
My main worry is fixpoint convergence because a query might never converge if the order keeps changing between iterations (remember exported_names). Because of that, changing the type for cyclic queries is only safe if we know the query converges on consistent ordering. I don't have a good sense for when this is safe and simply changing all types seems too high risk to me for what we gain (I don't mind migrating one by one or defaulting to orderedmap in the future) |
|
It might make sense to pare this down to just the dependency version bumps, and make a collective mental note that we no longer have to use |
Yes, that sounds good to me. It should also be safe to change |
|
Please retitle the PR before landing. |
ordermap
As part of an earlier version of #21784, I added upstream
salsaandget_size2support forordermap, but that ended up not being needed in the current version of that PR. However, @ibraheemdev has mentioned that we might like to switch toordermapacross the board once thesalsasupport was there. So I'm separating out these changes into this separate PR, and I'm expanding them to entirely removeindexmapas a dependency ofty_python_semantic. Do we like these changes?