Skip to content

Display full type of left operand in error messages #3147

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

Merged
merged 5 commits into from
Apr 12, 2017

Conversation

elazarg
Copy link
Contributor

@elazarg elazarg commented Apr 9, 2017

Remember the bound type of the self argument, allowing more consistent error messages.
For example, currently left and right operands are displayed differntly:

$ cat tmp.py
class A:
    def __add__(self, other: A): return self
a = A()
(a, a) + a
a + (a, a)
$ mypy tmp.py
tmp.py:3: error: Unsupported operand types for + ("tuple" and "A")
tmp.py:5: error: Unsupported operand types for + ("A" and "Tuple[A, A]")

Left and right operands are not treated the same way.

@gvanrossum
Copy link
Member

The new errors look like this:

__tmp__.py:4: error: Unsupported operand types for + ("Tuple[A, A]" and "A")
__tmp__.py:5: error: Unsupported operand types for + ("A" and "Tuple[A, A]")

Thanks! Reviewing now.

@gvanrossum gvanrossum merged commit 92e3b3e into python:master Apr 12, 2017
@gvanrossum
Copy link
Member

Whoops, does the new attribute need to be serialized?

@elazarg
Copy link
Contributor Author

elazarg commented Apr 12, 2017

I guess it does

@elazarg
Copy link
Contributor Author

elazarg commented Apr 12, 2017

Why not?

@gvanrossum
Copy link
Member

Sorry, never mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants