from typing import overload, Literal, List, Tuple, Any class Example: pass class Prediction: pass class TestMypy: @overload def __call__( self, program, return_all_scores: Literal[True] = ..., return_outputs: Literal[True] = ..., ) -> Tuple[float, List[Tuple[Example, Prediction, Any]], List[float]]: ... @overload def __call__( self, program, return_all_scores: Literal[True] = ..., return_outputs: Literal[False] = ..., ) -> Tuple[float, List[float]]: ... @overload def __call__( self, program, return_all_scores: Literal[False] = ..., return_outputs: Literal[True] = ..., ) -> Tuple[float, List[Tuple[Example, Prediction, Any]]]: ... @overload def __call__( self, program, return_all_scores: Literal[False] = ..., return_outputs: Literal[False] = ..., ) -> float: ... def __call__( self, program, return_all_scores: bool = False, return_outputs: bool = False, ): if return_all_scores: if return_outputs: return 0.1, [(Example(), Prediction(), 0.1)], [0.1] else: return 0.1, [0.1] elif return_outputs: return 0.1, [(Example(), Prediction(), 0.1)] else: return 0.1