[ty] Infer dict(**TypedDict) in TypedDict context#24709
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 88.70%. The percentage of expected errors that received a diagnostic held steady at 84.63%. The number of fully passing files held steady at 84/134. |
Memory usage reportMemory usage unchanged ✅ |
|
Merging this PR will not alter performance
Comparing Footnotes
|
e334d71 to
f1cbea9
Compare
c15a2b6 to
e52290a
Compare
e52290a to
e85a148
Compare
e85a148 to
fdf4b18
Compare
|
The upstream issue says "This showed up in hydpy in the ecosystem report on #24653 …". Should we expect any hydpy ecosystem changes on this PR? Also, the PR descriptions says "So the following are accepted […]", but I still get two errors for that snippet on this branch? (I guess it only works if |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
fdf4b18 to
76788a7
Compare
| keyword_ty.is_dynamic() | ||
| || keyword_ty.is_never() |
There was a problem hiding this comment.
Can you explain these two checks here? No tests fail when I remove them.
There is one test that looks like it's testing something similar (maybe_td), but it does not fail when I remove these. Neither does any other test.
Is the intent to cover something like this?
def _(unknown) -> None:
td_unknown: TD = dict(**unknown)If so, isn't there a more principled check that we could perform here instead? Like
| keyword_ty.is_dynamic() | |
| || keyword_ty.is_never() | |
| keyword_ty | |
| .is_assignable_to(speculative_builder.db(), Type::TypedDict(typed_dict)) |
76788a7 to
bb3fc91
Compare
Summary
Given, e.g.,
def f() -> TD: return dict(**src), we now inferdict(**src)as matchingTDifsrcisTD, for example. So the following are accepted, whereas on main they all produce diagnostics: