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 'Union[Unknown, int]' and 'Union[Unknown, Type[int]] #90

Closed
starship863 opened this issue Apr 26, 2019 · 2 comments
Labels
bug Something isn't working

Comments

@starship863
Copy link

Describe the bug
Pyright produces problem for simple "a + 1" as Operator '+' not supported for types 'int' and 'Enum[Unknown, Type[int]]'

To Reproduce
create a new .py file and write

a: int
a + 1

Expected behavior
No problem should be produced

Screenshots or Code
image

VS Code extension or command-line
I am running pyright as a VS Code extension 1.0.17

Additional context
When I reload the vscode window, the problem goes away.

erictraut pushed a commit that referenced this issue Apr 26, 2019
…t upon int/float/complex when operand is unioned with an unknown or any type.
@erictraut
Copy link
Collaborator

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

If you're curious, the problem is due to the fact that the standard typeshed stubs don't declare arithmetic operators (like __add__) as taking parameters of type int, float or complex. Because of this, the type checker needs to special-case these conditions. My special-case code didn't handle the case where the parameter type was a union of an unknown and one of these known types.

@erictraut erictraut added the bug Something isn't working label Apr 26, 2019
@erictraut
Copy link
Collaborator

This is now fixed in version 1.0.18, which I just published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants