Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Using the collecting variable of iterable unpacking causes "used before definition" error #461

Closed
brettcannon opened this issue Dec 5, 2018 · 2 comments
Assignees

Comments

@brettcannon
Copy link
Member

microsoft/vscode-python#3543

a, *b, c = range(5)
print(b)

b ends up being reported as used before definition.

@jakebailey
Copy link
Member

My guess (without looking too hard) is that we aren't handling this style of unpack properly (see #412, #403), and we're considering it to be a use like it's a mul or a args/kwargs unpack.

@md2perpe
Copy link

I got the same error in a loop construction like

for first, *rest in data:
    use(first, rest)

Here, rest gets reported as used before definition on the use line.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants