Skip to content

Commit

Permalink
chore: remove unused type ignores (#1137)
Browse files Browse the repository at this point in the history
* chore: remove unused type ignores

---------

Co-authored-by: Sebastian Niehus <[email protected]>
  • Loading branch information
bluenote10 and SebastianNiehusAA authored Nov 14, 2024
1 parent f2d4387 commit fd9efa4
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]

warn_unused_ignores = True
4 changes: 3 additions & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -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 .
6 changes: 2 additions & 4 deletions src/intelligence_layer/evaluation/aggregation/accumulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/intelligence_layer/evaluation/evaluation/graders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/connectors/test_limited_concurrency_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fd9efa4

Please sign in to comment.