Skip to content

Commit

Permalink
update lint
Browse files Browse the repository at this point in the history
  • Loading branch information
artoonie committed Jun 9, 2023
1 parent 64be178 commit a97e1f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 5 additions & 4 deletions rcvformats/conversions/dominion_xlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from openpyxl.cell.read_only import EmptyCell, ReadOnlyCell

from rcvformats.conversions.base import GenericGuessAtTransferConverter
from rcvformats.schemas.base import DataError


class DominionXlsxConverter(GenericGuessAtTransferConverter):
Expand Down Expand Up @@ -91,7 +92,7 @@ def _count_num_header_rows(cls, sheet):
continue

return row
raise Exception("Could not find the end of the headers")
raise DataError("Could not find the end of the headers")

def _find_row_of_inactive_ballots(self, sheet, num_candidates):
"""
Expand All @@ -105,7 +106,7 @@ def _find_row_of_inactive_ballots(self, sheet, num_candidates):
for row in range(row + min_num_rows, row + max_num_rows):
if sheet.cell(row, 1).value == "Non Transferable Total":
return row
raise Exception("Could not find the end of the non-transferable rows")
raise DataError("Could not find the end of the non-transferable rows")

def _try_to_find_row_of_threshold(self, sheet, inactive_row):
"""
Expand Down Expand Up @@ -192,7 +193,7 @@ def _parse_rounds(self):

col += 1
if col >= max_cols:
raise Exception("This document is not in the correct format..."
raise DataError("This document is not in the correct format..."
"or there are more than 500 rounds")

# Is this a merged cell? If so, ignore it.
Expand Down Expand Up @@ -241,7 +242,7 @@ def _parse_candidates(self):
if candidate_name == end_of_candidates_marker:
break
if row == max_num_rows:
raise Exception("This document is not in the correct format..."
raise DataError("This document is not in the correct format..."
"or there are more than 500 candidates")
cell = self.sheet['A' + str(row)]
name = cell.value
Expand Down
4 changes: 2 additions & 2 deletions rcvformats/conversions/electionbuddy.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _threshold_for_round(cls, rounds, round_i):
return rounds[round_i]['threshold']

last_round = rounds[-1]
num_voters_in_last_round = sum([v for k, v in last_round['candidates'].items()])
num_voters_in_last_round = sum(v for (k, v) in last_round['candidates'].items())
return num_voters_in_last_round / 2.0

@classmethod
Expand Down Expand Up @@ -109,5 +109,5 @@ def _get_threshold(cls, csv_data):
if last_round['threshold']:
return last_round['threshold']

num_voters_in_last_round = sum([v for k, v in last_round['candidates'].items()])
num_voters_in_last_round = sum(v for (k, v) in last_round['candidates'].items())
return num_voters_in_last_round / 2.0
3 changes: 1 addition & 2 deletions rcvformats/conversions/opavote.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ def _convert_file_object_to_ut(self, file_object):
'round': round_i + 1,
'tally': {}
}
for candidate_i, _ in enumerate(candidate_names):
for candidate_i, name in enumerate(candidate_names):
votes = self._votes_on_round(candidate_i, rounds, round_i)
name = candidate_names[candidate_i]
ut_round['tally'][name] = votes
ut_rounds.append(ut_round)

Expand Down

0 comments on commit a97e1f3

Please sign in to comment.