Repository navigation
Checking of starred expressions - #483
Conversation
…d within the index of for-statements.
…de (possibly a tuple) instead of a list. Updated tests accordingly.
|
What is currently missing are type annotations for starred expressions. I propose to follow the same syntax as used for the starred expressions themselves, like: a, *b = lijst # type: int, *List[int]
# b has type List[int]
*(p, q), r = rij # type: *(int, int), int
# p and q have type intThis would introduce a new type node In addition: Type inference of rvalues from the lvalue is probably not working correctly for nested starred expressions. However, if don't know how to test this. Input is welcome. |
…es (e.g. of for-stmts)
… is present in a tuple
… number in type annotation error message.
|
I've implemented the starred type annotations I proposed in the previous comment. |
|
Thanks for implementing this! I did a first review pass and it looks excellent. I'm going to play around with it a bit a look at the diff in more detail. |
There was a problem hiding this comment.
This fails in case of nested star expressions, like a, *(b, *c) = x. I'd like to fix it, but I have trouble coming up with a test case for type inference from lvalues.
I guess it is not very common, though, and not very useful.
|
Apologies for the delay, we have my parents visiting from Finland and I haven't been able to keep up with code reviews. Sorry! |
|
Take your time. |
|
I updated the documentation update to reflect the new documentation structure. Once more, thanks for adding this feature! |
This PR brings type checking of starred expressions in assignments (
*rest, last = 1,2,3) and as index of for-statements ([head for head, *tail in L]).In 9986cef, I have replaced the index of for-statements and generator expressions from being a list of
Nodes to a singleNode(which will be a tuple, of course, when the list would have had more than one element before the change). Consequently, several testcases have changed in that commit, because the AST/parse tree changed a bit.