diff --git a/pupa/importers/bills.py b/pupa/importers/bills.py index bfeb964..5cc1665 100644 --- a/pupa/importers/bills.py +++ b/pupa/importers/bills.py @@ -111,13 +111,18 @@ def postimport(self): # go through all RelatedBill objs that are attached to a bill in this # jurisdiction and are currently unresolved for rb in RelatedBill.objects.filter( - bill__legislative_session__jurisdiction_id=self.jurisdiction_id, - related_bill=None): - candidates = list(Bill.objects.filter( - Q(legislative_session__identifier=rb.legislative_session, - legislative_session__jurisdiction_id=self.jurisdiction_id), - Q(identifier=rb.identifier) | - Q(other_identifiers__identifier=rb.identifier)) + bill__legislative_session__jurisdiction_id=self.jurisdiction_id, + related_bill=None, + ): + candidates = list( + Bill.objects.filter( + Q( + legislative_session__identifier=rb.legislative_session, + legislative_session__jurisdiction_id=self.jurisdiction_id, + ), + Q(identifier=rb.identifier) + | Q(other_identifiers__identifier=rb.identifier), + ) ) if len(candidates) == 1: rb.related_bill = candidates[0] diff --git a/pupa/importers/vote_events.py b/pupa/importers/vote_events.py index ebefabf..be144a0 100644 --- a/pupa/importers/vote_events.py +++ b/pupa/importers/vote_events.py @@ -99,8 +99,9 @@ def prepare_for_db(self, data): organization_id=data["organization_id"], ) if action.id in self.seen_action_ids: - self.warning('can not match two VoteEvents to %s: %s', - action.id, bill_action) + self.warning( + "can not match two VoteEvents to %s: %s", action.id, bill_action + ) else: data["bill_action_id"] = action.id self.seen_action_ids.add(action.id)