-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
datetime.datetime.utcnow is deprecated since 3.12: https://docs.python.org/3/library/datetime.html#datetime.datetime.utcnow
I started with a naive patch but ran into some issue with the Bugzilla handling:
diff --git a/nattka/__main__.py b/nattka/__main__.py
index a141cea..748364d 100644
--- a/nattka/__main__.py
+++ b/nattka/__main__.py
@@ -395,7 +395,7 @@ class NattkaCommands(object):
repo, git_repo = self.get_git_repository()
with git_repo:
- start_time = datetime.datetime.utcnow()
+ start_time = datetime.datetime.now(datetime.timezone.utc)
packages = self.args.package
if self.args.arch is None:
initial_arches = '*'
@@ -483,7 +483,7 @@ class NattkaCommands(object):
it += 1
- end_time = datetime.datetime.utcnow()
+ end_time = datetime.datetime.now(datetime.timezone.utc)
log.info(f'Time elapsed: {end_time - start_time}')
log.info(f'Target CC: {" ".join(cc_arches)}')
@@ -559,7 +559,7 @@ class NattkaCommands(object):
cache = self.get_cache()
cache.setdefault('bugs', {})
- start_time = datetime.datetime.utcnow()
+ start_time = datetime.datetime.now(datetime.timezone.utc)
log.info(f'NATTkA starting at {start_time}')
end_time = None
if self.args.time_limit is not None:
@@ -579,7 +579,7 @@ class NattkaCommands(object):
log.info(f'Reached limit of {self.args.bug_limit} bugs')
break
if (end_time is not None
- and datetime.datetime.utcnow() > end_time):
+ and datetime.datetime.now(datetime.timezone.utc) > end_time):
log.info('Reached time limit')
break
@@ -728,7 +728,7 @@ class NattkaCommands(object):
is not b.sanity_check):
log.info('Sanity-check flag changed, '
'will recheck.')
- elif (datetime.datetime.utcnow()
+ elif (datetime.datetime.now(datetime.timezone.utc)
- datetime.datetime.strptime(
last_check, '%Y-%m-%dT%H:%M:%S')
> datetime.timedelta(
@@ -754,7 +754,7 @@ class NattkaCommands(object):
cache_entry = cache['bugs'][str(bno)] = {
'last-check':
- datetime.datetime.utcnow().isoformat(
+ datetime.datetime.now(datetime.timezone.utc).isoformat(
timespec='seconds'),
'package-list': plist_json,
'check-res': check_res,
@@ -889,7 +889,7 @@ class NattkaCommands(object):
log.info(f'New comment: {comment}')
finally:
self.write_cache(cache)
- end_time = datetime.datetime.utcnow()
+ end_time = datetime.datetime.now(datetime.timezone.utc)
log.info(f'NATTkA exiting at {end_time}')
log.info(f'Total time elapsed: {end_time - start_time}')
diff --git a/nattka/bugzilla.py b/nattka/bugzilla.py
index 848f4cb..11fa6ae 100644
--- a/nattka/bugzilla.py
+++ b/nattka/bugzilla.py
@@ -92,7 +92,7 @@ class BugInfo(typing.NamedTuple):
keywords: typing.List[str] = []
whiteboard: str = ''
assigned_to: str = ''
- last_change_time: datetime.datetime = datetime.datetime.utcnow()
+ last_change_time: datetime.datetime = datetime.datetime.now(datetime.timezone.utc)
runtime_testing_required: typing.Optional[BugRuntimeTestingState] = None
diff --git a/nattka/keyword.py b/nattka/keyword.py
index faeefa4..f109416 100644
--- a/nattka/keyword.py
+++ b/nattka/keyword.py
@@ -36,7 +36,7 @@ def keyword_sort_key(kw: str
def update_copyright(copyright_line: str,
- target_year: int = datetime.datetime.utcnow().year,
+ target_year: int = datetime.datetime.now(datetime.timezone.utc).year,
) -> str:
"""
Update copyright date and owner in `copyright_line`.
diff --git a/test/test_integration.py b/test/test_integration.py
index cc00fbd..efc8977 100644
--- a/test/test_integration.py
+++ b/test/test_integration.py
@@ -873,7 +873,7 @@ class IntegrationSuccessTests(IntegrationTestCase):
@patch('nattka.__main__.NattkaBugzilla')
def test_sanity_cache_expired(self, bugz, add_keywords):
bugz_inst = self.bug_preset(bugz, initial_status=True)
- last_check = datetime.datetime.utcnow() - datetime.timedelta(days=1)
+ last_check = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=1)
with patch('nattka.__main__.datetime.datetime') as mocked_dt:
mocked_dt.utcnow.return_value = last_check
self.assertEqual(Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels