You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The common case should actually be pretty easy to implement by just special casing this in the semantic analyzer and using the analyzed attribute of the dict(...)CallExpr to store a DictExpr when the call only uses keyword arguments. The dict literal keys should be string literals generated from the keyword argument names, and the dict values are just the argument expressions.
The **args case is trickier, but this seems rare so we don't need to support it yet.
This now works but for heterogeneous dictionaries the inferred type will likely be Dict[str, object] unless there is an explicit type annotation, so this isn't super useful yet.
Activity
JukkaL commentedon Oct 12, 2014
The common case should actually be pretty easy to implement by just special casing this in the semantic analyzer and using the
analyzedattribute of thedict(...)CallExprto store aDictExprwhen the call only uses keyword arguments. The dict literal keys should be string literals generated from the keyword argument names, and the dict values are just the argument expressions.The
**argscase is trickier, but this seems rare so we don't need to support it yet.JukkaL commentedon Aug 23, 2015
Increasing priority as this is actually a pretty common issue.
gvanrossum commentedon Nov 22, 2015
Yeah, I see this a lot in our latest demo project.
JukkaL commentedon Nov 22, 2015
This now works but for heterogeneous dictionaries the inferred type will likely be
Dict[str, object]unless there is an explicit type annotation, so this isn't super useful yet.