Skip to content

Work in Progress CallableType usingpretty_callable_or_overload #19027

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions mypy/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,24 +404,38 @@ def has_no_attr(
self.unsupported_left_operand(op, original_type, context)
return codes.OPERATOR
elif member == "__neg__":
display_type = (
self.pretty_callable_or_overload(original_type)
if isinstance(original_type, CallableType)
else format_type(original_type, self.options)
)
self.fail(
f"Unsupported operand type for unary - ({format_type(original_type, self.options)})",
f"Unsupported operand type for unary - ({display_type})",
context,
code=codes.OPERATOR,
)
return codes.OPERATOR
elif member == "__pos__":

display_type = (
self.pretty_callable_or_overload(original_type)
if isinstance(original_type, CallableType)
else format_type(original_type, self.options)
)
self.fail(
f"Unsupported operand type for unary + ({format_type(original_type, self.options)})",
f"Unsupported operand type for unary + ({display_type})",
context,
code=codes.OPERATOR,
)
return codes.OPERATOR
elif member == "__invert__":
display_type = (
self.pretty_callable_or_overload(original_type)
if isinstance(original_type, CallableType)
else format_type(original_type, self.options)
)
self.fail(
f"Unsupported operand type for ~ ({format_type(original_type, self.options)})",
context,
code=codes.OPERATOR,
f"Unsupported operand type for ~ ({display_type})", context, code=codes.OPERATOR
)
return codes.OPERATOR
elif member == "__getitem__":
Expand Down
Loading