Skip to content

Commit 9a1776e

Browse files
authored
scrapers: replace deprecated Logger.warn with .warning (#5677)
Logger.warn was deprecated back in Python 3.3 in favour of .warning, and the bare warn shim warns on import in 3.13. Sweep the 15 call sites across MA, NY, OR, and utils. Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
1 parent 6d6cb0f commit 9a1776e

6 files changed

Lines changed: 15 additions & 15 deletions

File tree

scrapers/ma/votes.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def process_page(self):
162162
# If they disagree on number of matches, the scraper will not get
163163
# the data correctly so emit a warning and skip this pdf.
164164
if not (len(votes_mt) == len(votes_s) == len(votes_id)):
165-
self.logger.warn(
165+
self.logger.warning(
166166
f"\nCould not accurately parse votes for "
167167
f"{self.source.url}\n"
168168
f"len(votes_mt):{len(votes_mt)}\n"
@@ -184,7 +184,7 @@ def process_page(self):
184184
def parse_match(self, match, index):
185185
bill_id = self.get_bill_id(index)
186186
if not bill_id:
187-
self.logger.warn(
187+
self.logger.warning(
188188
f"No valid bill id found preceding vote lines in {self.source.url}"
189189
)
190190
return {}
@@ -224,7 +224,7 @@ def parse_match(self, match, index):
224224
if motion_text:
225225
motion_text = motion_text.group(1)
226226
else:
227-
self.logger.warn(
227+
self.logger.warning(
228228
f"No valid motion text found preceding vote lines in {self.source}"
229229
)
230230
return
@@ -239,7 +239,7 @@ def parse_match(self, match, index):
239239
break
240240

241241
if not vote_classification:
242-
self.logger.warn(
242+
self.logger.warning(
243243
f"""
244244
No vote_classification from {single_line_motion}" in journal at {self.source.url}
245245
"""
@@ -293,7 +293,7 @@ def parse_match(self, match, index):
293293
yea_mismatch = first_total_yea != total_yea
294294
nay_mismatch = first_total_nay != total_nay
295295
if yea_mismatch or nay_mismatch:
296-
self.logger.warn(
296+
self.logger.warning(
297297
f"Cannot accurately parse to determine margins for vote {index + 1} in {self.source.url}"
298298
)
299299
return {}
@@ -304,7 +304,7 @@ def parse_match(self, match, index):
304304
for miscount in yea_matches_miscount, nay_matches_miscount:
305305
# Allows for minor miscount in cases of PDF formatting issues
306306
if abs(miscount) > determinative_margin:
307-
self.logger.warn(
307+
self.logger.warning(
308308
f"Cannot accurately parse to determine margins for vote {index + 1} in {self.source.url}"
309309
)
310310
return {}
@@ -346,7 +346,7 @@ def get_bill_id(self, index):
346346
chamber, number = bill_id_match[-1]
347347
self.bill_id = f"{chamber[0]} {number}"
348348
if not self.bill_id:
349-
self.logger.warn(
349+
self.logger.warning(
350350
f"No preceding bill id for vote {index + 1} in {self.source.url}"
351351
)
352352
return self.bill_id
@@ -516,7 +516,7 @@ def process_page(self):
516516
for vote in vote_text:
517517
vote_parser = HouseVoteRecordParser(vote, session=self.session)
518518
if (warning := vote_parser.get_warning()) is not None:
519-
self.logger.warn(warning)
519+
self.logger.warning(warning)
520520
else:
521521
vote_parser.error_if_invalid()
522522
vote_event = vote_parser.createVoteEvent()

scrapers/ny/bills.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def _parse_bill_details(self, bill):
5151
title = bill["title"].strip()
5252

5353
if not title:
54-
self.logger.warn("Bill missing title.")
54+
self.logger.warning("Bill missing title.")
5555
return
5656

5757
# Determine the chamber the bill originated from.
@@ -61,7 +61,7 @@ def _parse_bill_details(self, bill):
6161
bill_chamber = "lower"
6262
else:
6363
warning = "Could not identify chamber for {}."
64-
self.logger.warn(warning).format(bill_id)
64+
self.logger.warning(warning).format(bill_id)
6565

6666
senate_url = (
6767
"http://www.nysenate.gov/legislation/bills/{bill_session}/" "{bill_id}"

scrapers/or/bills.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def scrape_bills(self, session):
8888
try:
8989
legislator = legislators[legislator_code]
9090
except KeyError:
91-
logger.warn(
91+
logger.warning(
9292
"Legislator {} not found in session {}".format(
9393
legislator_code, session
9494
)
@@ -118,7 +118,7 @@ def scrape_bills(self, session):
118118
media_type="application/pdf",
119119
)
120120
except ValueError:
121-
logger.warn("Duplicate link found for {}".format(document_url))
121+
logger.warning("Duplicate link found for {}".format(document_url))
122122

123123
for agenda_item in measure["CommitteeAgendaItems"]:
124124
for document in agenda_item["CommitteeProposedAmendments"]:

scrapers/or/committees.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def scrape_committees(self, session):
4141
try:
4242
member_name = legislators[member["LegislatorCode"]]
4343
except KeyError:
44-
logger.warn(
44+
logger.warning(
4545
"Legislator {} not found in session {}".format(
4646
member["LegislatorCode"], session_key
4747
)

scrapers/or/votes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def add_individual_votes(self, vote, vote_call, vote_type):
150150
try:
151151
voter_name = self.legislators[voter["VoteName"]]
152152
except KeyError:
153-
logger.warn(
153+
logger.warning(
154154
"Legislator {} not found in session {}".format(
155155
voter["VoteName"], self.session_key
156156
)

scrapers/utils/votes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ def check_counts(vote, raise_error=False):
2222
if raise_error:
2323
raise ValueError(msg)
2424
else:
25-
logger.warn(msg)
25+
logger.warning(msg)

0 commit comments

Comments
 (0)