Last active
May 2, 2024 16:48
-
-
Save rpgoldman/91b1d0b20e09a4b5f27dbf3d395a8217 to your computer and use it in GitHub Desktop.
Revisions
-
rpgoldman revised this gist
May 2, 2024 . 2 changed files with 75 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ $ poetry run mypy dspy/evaluate/mypy_issue.py dspy/evaluate/mypy_issue.py:13: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:13: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:13: error: Overloaded function signatures 1 and 4 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:23: error: Overloaded function signatures 2 and 3 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:23: error: Overloaded function signatures 2 and 4 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:33: error: Overloaded function signatures 3 and 4 overlap with incompatible return types [overload-overlap] Found 6 errors in 1 file (checked 1 source file) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,67 @@ from typing import overload, Literal, List, Tuple, Any class Example: pass class Prediction: pass class TestMypy: @overload def __call__( self, program, foo: int = ..., return_all_scores: Literal[True] = ..., return_outputs: Literal[True] = ..., ) -> Tuple[float, List[Tuple[Example, Prediction, Any]], List[float]]: ... @overload def __call__( self, program, foo: int = ..., return_all_scores: Literal[True] = ..., return_outputs: Literal[False] = ..., ) -> Tuple[float, List[float]]: ... @overload def __call__( self, program, foo: int = ..., return_all_scores: Literal[False] = ..., return_outputs: Literal[True] = ..., ) -> Tuple[float, List[Tuple[Example, Prediction, Any]]]: ... @overload def __call__( self, program, foo: int = ..., return_all_scores: Literal[False] = ..., return_outputs: Literal[False] = ..., ) -> float: ... def __call__( self, program, foo: int = 5, return_all_scores: bool = False, return_outputs: bool = False, ): if return_all_scores: if return_outputs: return foo, [(Example(), Prediction(), 0.1)], [0.1] else: return foo, [0.1] elif return_outputs: return foo, [(Example(), Prediction(), 0.1)] else: return foo -
rpgoldman revised this gist
May 1, 2024 . 2 changed files with 8 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ $ poetry run mypy dspy/evaluate/mypy_issue.py dspy/evaluate/mypy_issue.py:13: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:13: error: Overloaded function signatures 1 and 3 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:13: error: Overloaded function signatures 1 and 4 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:22: error: Overloaded function signatures 2 and 3 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:22: error: Overloaded function signatures 2 and 4 overlap with incompatible return types [overload-overlap] dspy/evaluate/mypy_issue.py:31: error: Overloaded function signatures 3 and 4 overlap with incompatible return types [overload-overlap] Found 6 errors in 1 file (checked 1 source file) -
rpgoldman created this gist
May 1, 2024 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,62 @@ 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