Skip to content

Commit 07b297e

Browse files
authored
[Bot] FIX stale.py uses timezone-aware datetime (huggingface#5396)
reflect stalebot change from huggingface/peft#1016
1 parent 2bfa55f commit 07b297e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

utils/stale.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""
1818
import os
1919
from datetime import datetime as dt
20+
from datetime import timezone
2021

2122
from github import Github
2223

@@ -43,8 +44,8 @@ def main():
4344
if (
4445
last_comment is not None
4546
and last_comment.user.login == "github-actions[bot]"
46-
and (dt.utcnow() - issue.updated_at).days > 7
47-
and (dt.utcnow() - issue.created_at).days >= 30
47+
and (dt.now(timezone.utc) - issue.updated_at).days > 7
48+
and (dt.now(timezone.utc) - issue.created_at).days >= 30
4849
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
4950
):
5051
# Closes the issue after 7 days of inactivity since the Stalebot notification.
@@ -58,8 +59,8 @@ def main():
5859
issue.edit(state="open")
5960
issue.remove_from_labels("stale")
6061
elif (
61-
(dt.utcnow() - issue.updated_at).days > 23
62-
and (dt.utcnow() - issue.created_at).days >= 30
62+
(dt.now(timezone.utc) - issue.updated_at).days > 23
63+
and (dt.now(timezone.utc) - issue.created_at).days >= 30
6364
and not any(label.name.lower() in LABELS_TO_EXEMPT for label in issue.get_labels())
6465
):
6566
# Post a Stalebot notification after 23 days of inactivity.

0 commit comments

Comments
 (0)