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

No overloads for "raises" match the provided arguments: Type[Exception] #1003

Closed
cdonnellytx opened this issue Mar 1, 2021 · 3 comments
Closed
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version

Comments

@cdonnellytx
Copy link

Getting a false positive of No overloads for "raises" match the provided arguments" if I pass type(exception) to a method, whereas using an intermediate variable does not raise the error.

Environment data

  • Language Server version: 2021.2.4, 2021.2.5-pre.1
  • OS and version: Windows 10 20H2 (19042.804)
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.8.6

Expected behaviour

Neither line should show an error.

Actual behaviour

pytest.raises(type(exception)) is flagged as an error, pytest.raises(exception_type) is not.

Logs

Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
[FG] parsing: d:\temp\foo.py (53ms)
[FG] parsing: c:\Users\x\.vscode\extensions\ms-python.vscode-pylance-2021.2.5-pre.1\dist\typeshed-fallback\stdlib\builtins.pyi [fs read 1ms] (166ms)
[FG] binding: c:\Users\x\.vscode\extensions\ms-python.vscode-pylance-2021.2.5-pre.1\dist\typeshed-fallback\stdlib\builtins.pyi (30ms)
[FG] binding: d:\temp\foo.py (1ms)
Background analysis message: analyze
[BG(1)] analyzing: d:\temp\foo.py ...
[BG(1)]   parsing: d:\temp\foo.py (9ms)
[BG(1)]   binding: d:\temp\foo.py (0ms)
[BG(1)]   checking: d:\temp\foo.py (8ms)
[BG(1)] analyzing: d:\temp\foo.py (19ms)
Background analysis message: getDiagnosticsForRange
Background analysis message: getSemanticTokens
Background analysis message: getSemanticTokens
Background analysis message: getDiagnosticsForRange
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange

Code Snippet / Additional information

NOTE: test block simplified for sample

import pytest

exception = Exception("foo")
exception_type = type(exception)

with pytest.raises(type(exception)):
    pass
with pytest.raises(exception_type):
    pass

Screenshot of above code

@github-actions github-actions bot added the triage label Mar 1, 2021
@erictraut
Copy link
Contributor

Thanks for the bug report. I'm able to repro the problem. I'll investigate further.

@erictraut erictraut added bug Something isn't working and removed triage labels Mar 1, 2021
@erictraut
Copy link
Contributor

This will be fixed in the next release.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Mar 1, 2021
@jakebailey
Copy link
Member

This issue has been fixed in version 2021.3.0, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202130-3-march-2021

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