Skip to content

Display full type of left operand in error messages - #3147

Merged
gvanrossum merged 5 commits into
python:masterfrom
elazarg:leftop-inconsistent
Apr 12, 2017
Merged

gvanrossum merged 5 commits into
python:masterfrom
elazarg:leftop-inconsistent

Conversation

@elazarg

@elazarg elazarg commented Apr 9, 2017 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Member

Whoops, does the new attribute need to be serialized?

@elazarg

elazarg commented Apr 12, 2017

Copy link
Copy Markdown
Contributor Author

I guess it does

@elazarg

elazarg commented Apr 12, 2017

Copy link
Copy Markdown
Contributor Author

Why not?

@gvanrossum

Copy link
Copy Markdown
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