Skip to content

Commit

Permalink
Merge pull request #5245 from openstates/va-bugfix-vote-value-unexpected
Browse files Browse the repository at this point in the history
VA: attempt to fix TypeError on unexpected votes value
  • Loading branch information
jessemortenson authored Jan 22, 2025
2 parents b817567 + f439c47 commit 1a7e837
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions scrapers/va/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ def add_votes(self, bill: Bill, legislation_id: str):
"legislationID": legislation_id,
}

vote_page_url = f"{self.base_url}/Vote/api/getvotebyidasync"
page = requests.get(
f"{self.base_url}/Vote/api/getvotebyidasync",
vote_page_url,
params=body,
headers=self.headers,
verify=False,
Expand All @@ -249,9 +250,16 @@ def add_votes(self, bill: Bill, legislation_id: str):
# and right now OS core requires a pass or fail, so we skip them with a notice
# also skip rows that correspond to a bill action that does not indicate a vote by presence of ##-Y / ##-N
# if we don't skip on that last criteria, we get duplicate vote events
if (
row["PassFail"] or row["IsVoice"] is not True
) and vote_shorthand_regex.search(row["LegislationActionDescription"]):
try:
vote_shorthand_match = vote_shorthand_regex.search(
row["LegislationActionDescription"]
)
except TypeError:
self.logger.warning(
f"Failed to process vote due to unexpected LegislativeActionDescription on {vote_page_url}"
)
vote_shorthand_match = False
if (row["PassFail"] or row["IsVoice"] is not True) and vote_shorthand_match:
vote_date = dateutil.parser.parse(row["VoteDate"]).date()

motion_text = row["VoteActionDescription"]
Expand Down

0 comments on commit 1a7e837

Please sign in to comment.