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

isinstance & Callable #247

Closed
cgarciae opened this issue Aug 15, 2020 · 2 comments
Closed

isinstance & Callable #247

cgarciae opened this issue Aug 15, 2020 · 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

@cgarciae
Copy link

Environment data

  • Language Server version: Pylance language server 2020.8.1 (pyright 0916fb9e)
  • OS and version: Ubuntu 20.04
  • Python version: 3.8.1

Actual behaviour

Recently I am getting a type issue when using isinstance to check for callables:

import typing as tp

def f():
    ...

print(isinstance(f, tp.Callable)) # Second argument to "isinstance" must be a class or tuple of classes
# TypeVar or generic type with type arguments is not allowedPylance (reportGeneralTypeIssues)

According to PEP 484 this should be supported:

Because typing.Callable does double-duty as a replacement for collections.abc.Callable , isinstance(x, typing.Callable) is implemented by deferring to `isinstance(x, collections.abc.Callable) . However, isinstance(x, typing.Callable[...]) is not supported.

Previous versions of Pylance where ok with this type of code.

@erictraut
Copy link
Contributor

Thanks for the bug report. This was a regression related to a recent change I made. I've fixed the problem and augmented the unit tests to prevent similar regressions in the future. The fix will be in the next version of pylance.

@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 labels Aug 15, 2020
@github-actions github-actions bot removed the triage label Aug 15, 2020
@jakebailey
Copy link
Member

This issue has been fixed in version 2020.8.2, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/master/CHANGELOG.md#202082-20-august-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