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

Tuple with TypeVar as Function Parameter: Expected class type but received "Literal[0]" #2169

Closed
FunkMonkey opened this issue Dec 13, 2021 · 2 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

@FunkMonkey
Copy link

FunkMonkey commented Dec 13, 2021

Environment data

  • Language Server version: 2021.12.1
  • OS and version: Windows 10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.96 64 bit Conda

Expected behaviour

No error when using a parameter of a tuple type that uses a TypeVar

Actual behaviour

Getting error when using a parameter of a tuple type that uses a TypeVar, see code below.

It seems to be a regression. I rolled back to Pylance 2021.11.2, which does not give me this error.

Logs

Code Snippet / Additional information

TNodeData = TypeVar("TNodeData")
TestTuple = Tuple[int, TNodeData]

test1: TestTuple[str] = (34234, "hello")
x = test1[0] # no error as expected

def some_func(node: TestTuple[str]):
    some_var= node[0] # unexpected error: Expected class type but received "Literal[0]"
@erictraut
Copy link
Contributor

Thanks for the bug report. This will be fixed in the next release.

@erictraut erictraut added bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version and removed triage labels Dec 13, 2021
@bschnurr
Copy link
Member

This issue has been fixed in version 2021.12.2, which we've just released. You can find the changelog here: CHANGELOG.md

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