diff --git a/utils/stale.py b/utils/stale.py index 12932f31c2..f9c0af89f5 100644 --- a/utils/stale.py +++ b/utils/stale.py @@ -17,6 +17,7 @@ https://github.com/allenai/allennlp. """ import os from datetime import datetime as dt +from datetime import timezone from github import Github @@ -43,8 +44,8 @@ def main(): if ( last_comment is not None and last_comment.user.login == "github-actions[bot]" - and (dt.utcnow() - issue.updated_at).days > 7 - and (dt.utcnow() - issue.created_at).days >= 30 + and (dt.now(timezone.utc) - issue.updated_at).days > 7 + and (dt.now(timezone.utc) - issue.created_at).days >= 30 and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()) ): # Closes the issue after 7 days of inactivity since the Stalebot notification. @@ -58,8 +59,8 @@ def main(): issue.edit(state="open") issue.remove_from_labels("stale") elif ( - (dt.utcnow() - issue.updated_at).days > 23 - and (dt.utcnow() - issue.created_at).days >= 30 + (dt.now(timezone.utc) - issue.updated_at).days > 23 + and (dt.now(timezone.utc) - issue.created_at).days >= 30 and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels()) ): # Post a Stalebot notification after 23 days of inactivity.