Skip to content

Commit

Permalink
Merge pull request #1726 from MVrachev/dateutil-remove
Browse files Browse the repository at this point in the history
Metadata API: remove dateutil requirement
  • Loading branch information
Jussi Kukkonen committed Dec 14, 2021
2 parents bdf1cbb + 181b1a7 commit f75b58c
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
4 changes: 0 additions & 4 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# pinned tuf runtime dependencies (should auto-update and -trigger ci/cd)
-r requirements-pinned.txt

# tuf.api tests use python-dateutil
python-dateutil

# additional test tools for linting and coverage measurement
coverage
black
Expand All @@ -14,4 +11,3 @@ pylint
mypy
bandit
types-requests
types-python-dateutil
10 changes: 0 additions & 10 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from datetime import datetime, timedelta
from typing import ClassVar, Dict

from dateutil.relativedelta import relativedelta
from securesystemslib import hash as sslib_hash
from securesystemslib.interface import (
import_ed25519_privatekey_from_file,
Expand Down Expand Up @@ -333,15 +332,6 @@ def test_metadata_timestamp(self) -> None:
timestamp.signed.bump_expiration(timedelta(days=365))
self.assertEqual(timestamp.signed.expires, datetime(2031, 1, 2, 0, 0))

# Test whether dateutil.relativedelta works, this provides a much
# easier to use interface for callers
delta = relativedelta(days=1)
timestamp.signed.bump_expiration(delta)
self.assertEqual(timestamp.signed.expires, datetime(2031, 1, 3, 0, 0))
delta = relativedelta(years=5)
timestamp.signed.bump_expiration(delta)
self.assertEqual(timestamp.signed.expires, datetime(2036, 1, 3, 0, 0))

# Create a MetaFile instance representing what we expect
# the updated data to be.
hashes = {
Expand Down
5 changes: 1 addition & 4 deletions tuf/api/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
cast,
)

from dateutil.relativedelta import relativedelta
from securesystemslib import exceptions as sslib_exceptions
from securesystemslib import hash as sslib_hash
from securesystemslib import keys as sslib_keys
Expand Down Expand Up @@ -501,9 +500,7 @@ def is_expired(self, reference_time: Optional[datetime] = None) -> bool:
return reference_time >= self.expires

# Modification.
def bump_expiration(
self, delta: Union[timedelta, relativedelta] = timedelta(days=1)
) -> None:
def bump_expiration(self, delta: timedelta = timedelta(days=1)) -> None:
"""Increments the expires attribute by the passed timedelta."""
self.expires += delta

Expand Down

0 comments on commit f75b58c

Please sign in to comment.