From f174dcaca41011c3ce07948ada2af0a0f2f876e4 Mon Sep 17 00:00:00 2001 From: Breno Raisch Date: Sun, 4 May 2025 18:57:54 -0300 Subject: [PATCH 1/2] Work in Progress CallableType usando pretty_callable_or_overload --- mypy/messages.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index 2e07d7f63498..f04097d1140a 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -404,22 +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)})", - context, - code=codes.OPERATOR, - ) + 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)})", + f"Unsupported operand type for ~ ({display_type})", context, code=codes.OPERATOR, ) From e675cc8cd0773dde9c4ddb135665a42a63db093b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 4 May 2025 22:00:49 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- mypy/messages.py | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/mypy/messages.py b/mypy/messages.py index f04097d1140a..18885b49ec29 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -405,39 +405,37 @@ def has_no_attr( 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.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 - ({display_type})", - context, - code=codes.OPERATOR, -) + f"Unsupported operand type for unary - ({display_type})", + context, + code=codes.OPERATOR, + ) return codes.OPERATOR elif member == "__pos__": - display_type=( + 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 + ({display_type})", + f"Unsupported operand type for unary + ({display_type})", context, code=codes.OPERATOR, ) return codes.OPERATOR elif member == "__invert__": - display_type=( + 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 ~ ({display_type})", - context, - code=codes.OPERATOR, + f"Unsupported operand type for ~ ({display_type})", context, code=codes.OPERATOR ) return codes.OPERATOR elif member == "__getitem__":