diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 00000000..a0392adf --- /dev/null +++ b/mypy.ini @@ -0,0 +1,3 @@ +[mypy] + +warn_unused_ignores = True diff --git a/scripts/lint.sh b/scripts/lint.sh index 97899bbf..db73e2cb 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -1,4 +1,6 @@ #!/usr/bin/env -S bash -eu -o pipefail +cd $(dirname $0)/.. + poetry run pre-commit run --all-files -poetry run mypy +poetry run mypy . diff --git a/src/intelligence_layer/evaluation/aggregation/accumulator.py b/src/intelligence_layer/evaluation/aggregation/accumulator.py index b085aa33..2b22d995 100644 --- a/src/intelligence_layer/evaluation/aggregation/accumulator.py +++ b/src/intelligence_layer/evaluation/aggregation/accumulator.py @@ -56,12 +56,10 @@ def standard_deviation(self) -> float: return 0.0 mean = self.extract() variance = (self._squares_acc / self._n) - (mean**2) - # not recognized as float by VSCode or mypy - return variance**0.5 # type: ignore + return variance**0.5 def standard_error(self) -> float: """Calculates the standard error of the mean.""" if self._n <= 1: return 0.0 - # not recognized as float by VSCode or mypy - return self.standard_deviation() / (self._n**0.5) # type: ignore + return self.standard_deviation() / (self._n**0.5) diff --git a/src/intelligence_layer/evaluation/aggregation/elo_aggregation.py b/src/intelligence_layer/evaluation/aggregation/elo_aggregation.py index 0dfe710a..fa1b5c64 100644 --- a/src/intelligence_layer/evaluation/aggregation/elo_aggregation.py +++ b/src/intelligence_layer/evaluation/aggregation/elo_aggregation.py @@ -81,8 +81,7 @@ def __init__( def _calc_k_factor(self, player: str) -> float: n = self._match_counts.get(player) or 0 - # Mypy thinks this is Any - return self._k_ceiling * np.exp(-self._decay_factor * n) + self._k_floor # type: ignore + return self._k_ceiling * np.exp(-self._decay_factor * n) + self._k_floor def _calc_expected_win_rates( self, player_a: str, player_b: str diff --git a/src/intelligence_layer/evaluation/evaluation/graders.py b/src/intelligence_layer/evaluation/evaluation/graders.py index ce369e18..7a500a58 100644 --- a/src/intelligence_layer/evaluation/evaluation/graders.py +++ b/src/intelligence_layer/evaluation/evaluation/graders.py @@ -28,7 +28,7 @@ def calculate_bleu(self, hypothesis: str, reference: str) -> float: hypotheses=[hypothesis], references=[[reference]] ) - return bleu_score.score # type: ignore + return bleu_score.score @dataclass diff --git a/src/intelligence_layer/learning/instruction_finetuning_data_handler.py b/src/intelligence_layer/learning/instruction_finetuning_data_handler.py index 7009d26d..daacba74 100644 --- a/src/intelligence_layer/learning/instruction_finetuning_data_handler.py +++ b/src/intelligence_layer/learning/instruction_finetuning_data_handler.py @@ -321,8 +321,7 @@ def samples_to_train_set( def process_sample( sample: InstructionFinetuningSample, # actual type is Synchronized[int] but declaring this will actually fail at runtime - # only declaring Synchronized will trigger mypy - emitted_counter: Synchronized, # type: ignore + emitted_counter: Synchronized, statistics_counter: dict[Any, dict[Any, int]], ) -> Optional[tuple[Sequence[FinetuningMessage], str]]: prompt = model.to_chat_prompt(sample.messages) diff --git a/tests/connectors/test_limited_concurrency_client.py b/tests/connectors/test_limited_concurrency_client.py index d041909e..89654c05 100644 --- a/tests/connectors/test_limited_concurrency_client.py +++ b/tests/connectors/test_limited_concurrency_client.py @@ -52,7 +52,7 @@ def complete(self, request: CompletionRequest, model: str) -> CompletionResponse if self.wait_time: time.sleep(self.wait_time) if self.number_of_retries < 2: - raise BusyError(503) # type: ignore + raise BusyError(503) else: if isinstance(self.return_value, Exception): raise self.return_value