Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enumerate(self) type unknown #423

Closed
fried opened this issue Sep 25, 2020 · 4 comments
Closed

enumerate(self) type unknown #423

fried opened this issue Sep 25, 2020 · 4 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@fried
Copy link

fried commented Sep 25, 2020

Environment data

  • Language Server version: 2020.9.6
  • OS and version: macOS 10.15.6
  • Python version (& distribution if applicable, e.g. Anaconda): cpython3.8.5

Expected behaviour

for i, value in enumerate(self): # (variable) value: bool
...

Actual behaviour

(variable) value: Unknown
Type of "value" is unknownPylance (reportUnknownVariableType)

But the following works just fine

for i, value in enumerate(BitBlob()):   # (variable) value: bool
     pass 

Code Snippet / Additional information

class BitBlob:
         def bad_types(self) -> None:
                for i, value in enumerate(self):
                      pass

         def good_types(self) -> None:
               for i, value in enumerate(BitBlob()):
                      pass

         def __iter__(self) -> Iterator[bool]:  ...
@fried
Copy link
Author

fried commented Sep 25, 2020

I have a workaround, this works even though it knew that self was a BitBlob before

def bad_types(self: BitBlob) -> None:
    for i, value in enumerate(self):
         pass

@jakebailey
Copy link
Member

jakebailey commented Sep 25, 2020

I can reproduce this.

image

image

image

@erictraut

@jakebailey jakebailey added the bug Something isn't working label Sep 25, 2020
@github-actions github-actions bot removed the triage label Sep 25, 2020
@jakebailey jakebailey added the needs investigation Could be an issue - needs investigation label Sep 25, 2020
@erictraut
Copy link
Contributor

Thanks for reporting the problem. This will be fixed in the next release.

@erictraut erictraut added fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed needs investigation Could be an issue - needs investigation labels Sep 25, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.9.7, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202097-30-september-2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version
Projects
None yet
Development

No branches or pull requests

3 participants