ruff
bc83869b - [ty] Reuse common protocol constraints for TypedDict unions (#25598)

Commit
5 days ago
[ty] Reuse common protocol constraints for TypedDict unions (#25598) ## Summary Prior to this change, inferring generic protocol type variables from a union of TypedDicts could be extremely slow... This affects calls like `dict(item)`, because the `dict` constructor accepts a generic structural protocol. When every member of a TypedDict-only union produces the same protocol constraints as `Mapping[str, object]`, we now reuse those common constraints instead of independently combining equivalent constraints from every union member. Ideally, we can remove this special-casing in the future, but it's now been reported twice so seems worth solving narrowly... Closes https://github.com/astral-sh/ty/issues/3625. Closes https://github.com/astral-sh/ty/issues/3521.
Author
Parents
Loading