Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Suppressing binary operation lint message #1319

Merged
merged 5 commits into from
Jul 15, 2019

Conversation

CTrando
Copy link
Contributor

@CTrando CTrando commented Jul 12, 2019

Fixes #1311

when we have

p = pathlib.Path.home() / 'tmp / 'tmp1'

we first evaluate

pathlib.Path.home() / 'tmp'

we say that pathlib.Path.home() is an unknown type, so doing this operation we get a string as a result.
Then we do

str / 'tmp'

which it thinks is an unsupported operand.

@jakebailey and I discussed, and we concluded there was not much we could do but just suppress this diagnostic for now. Operator overloading will continue to be an issue for this diagnostic.

@CTrando
Copy link
Contributor Author

CTrando commented Jul 12, 2019

Ran tests and all pass.

@MikhailArkhipov
Copy link

Actually, don't suppress it wholesale. If type is unknown it should be considered compatible. There are always going to be cases when we can't figure out some type.

@jakebailey
Copy link
Member

The problem is that we are getting cases where we infer the wrong thing (not just nothing), and then lint based on that behavior. We added this with the assumption that we always get the builtin types right, but we have cases where our backup cases in some places cause lint messages in others. I'm not sure if we want to surface all of these false positives...

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're just going to remove all of this code for now, rather than having it run and go nowhere.

@CTrando CTrando closed this Jul 15, 2019
@CTrando CTrando force-pushed the scratch/SuppressBinaryOp branch from 3673741 to 3170969 Compare July 15, 2019 19:40
…e types (microsoft#1254)"

This is due to the fact that current operator type checking is too
inaccurate to give diagnostics - operator overloading is a challenge to
face for the future

This reverts commit 753220f.
@CTrando CTrando reopened this Jul 15, 2019
@CTrando CTrando merged commit 157886e into microsoft:master Jul 15, 2019
jakebailey pushed a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
* Revert "Adding diagnostic error on binary operations with incompatible types (microsoft#1254)"

This is due to the fact that current operator type checking is too
inaccurate to give diagnostics - operator overloading is a challenge to
face for the future

This reverts commit 753220f.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pathlib path separators are incorrectly identified as unsupported string operand types.
3 participants