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

Operator "==" not supported for types Type[] #705

Closed
ytimenkov opened this issue Dec 9, 2020 · 2 comments
Closed

Operator "==" not supported for types Type[] #705

ytimenkov opened this issue Dec 9, 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

@ytimenkov
Copy link

Environment data

  • Language Server version: Pylance language server 2020.12.0 (pyright ea581b3f)
  • OS and version: Ubuntu 20.20
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.5 venv

Expected behaviour

I'm writing default exception handler and there I need to compare exception types:

import json
import sys
from types import TracebackType
from typing import Type, cast


def exception_handler(
    etype: Type[BaseException], exc: BaseException, tb: TracebackType
):
    if etype == json.decoder.JSONDecodeError:
        exc = cast(json.decoder.JSONDecodeError, exc)
        print(f"Invalid json:\n{exc.doc!r}")


sys.excepthook = exception_handler

json.loads("invalid")

Actual behaviour

Pylance complains:

Operator "==" not supported for types "Type[BaseException]" and "Type[JSONDecodeError]"
  Operator "==" not supported for types "Type[BaseException]" and "Type[JSONDecodeError]"Pylance (reportGeneralTypeIssues)

However running prints:

Invalid json:
'invalid'
@github-actions github-actions bot added the triage label Dec 9, 2020
@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 9, 2020
@jakebailey
Copy link
Member

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