diff --git a/docs/source/error_code_list.rst b/docs/source/error_code_list.rst index 64d9a1d03287..269cfa8d2f84 100644 --- a/docs/source/error_code_list.rst +++ b/docs/source/error_code_list.rst @@ -1151,6 +1151,23 @@ See :ref:`overloading ` for more explanation. .. _code-annotation-unchecked: +Check error code of overload function signature match +-------------------------------------------------------------------------- + +.. code-block:: python + + from typing import overload, Union + + @overload + def process(response1: float,response2: float) -> float: + ... + @overload + def process(response1: int,response2: int) -> int: # E: Overloaded function signature 2 will never be matched: signature 1's parameter type(s) are the same or broader [overloaded-function-matching] + ... + + def process(response1,response2)-> Union[float,int]: + return response1 + response2 + Notify about an annotation in an unchecked function [annotation-unchecked] -------------------------------------------------------------------------- diff --git a/mypy/messages.py b/mypy/messages.py index 62846c536f3d..ee7fb33056e7 100644 --- a/mypy/messages.py +++ b/mypy/messages.py @@ -1653,6 +1653,7 @@ def overloaded_signature_will_never_match( index1=index1, index2=index2 ), context, + code=codes.OVERLOADED_FUNCTION_MATCHING, ) def overloaded_signatures_typevar_specific(self, index: int, context: Context) -> None: