diff --git a/hcloud/actions/domain.py b/hcloud/actions/domain.py index e004be7..c3ea4cc 100644 --- a/hcloud/actions/domain.py +++ b/hcloud/actions/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -52,8 +52,8 @@ def __init__( self.status = status self.progress = progress - self.started = isoparse(started) if started else None - self.finished = isoparse(finished) if finished else None + self.started = datetime.fromisoformat(started) if started else None + self.finished = datetime.fromisoformat(finished) if finished else None self.resources = resources self.error = error diff --git a/hcloud/certificates/domain.py b/hcloud/certificates/domain.py index 46f1339..797d306 100644 --- a/hcloud/certificates/domain.py +++ b/hcloud/certificates/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain, DomainIdentityMixin @@ -59,9 +59,13 @@ def __init__( self.certificate = certificate self.domain_names = domain_names self.fingerprint = fingerprint - self.not_valid_before = isoparse(not_valid_before) if not_valid_before else None - self.not_valid_after = isoparse(not_valid_after) if not_valid_after else None - self.created = isoparse(created) if created else None + self.not_valid_before = ( + datetime.fromisoformat(not_valid_before) if not_valid_before else None + ) + self.not_valid_after = ( + datetime.fromisoformat(not_valid_after) if not_valid_after else None + ) + self.created = datetime.fromisoformat(created) if created else None self.labels = labels self.status = status diff --git a/hcloud/deprecation/domain.py b/hcloud/deprecation/domain.py index da96774..e7fa338 100644 --- a/hcloud/deprecation/domain.py +++ b/hcloud/deprecation/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -25,7 +25,7 @@ def __init__( announced=None, unavailable_after=None, ): - self.announced = isoparse(announced) if announced else None + self.announced = datetime.fromisoformat(announced) if announced else None self.unavailable_after = ( - isoparse(unavailable_after) if unavailable_after else None + datetime.fromisoformat(unavailable_after) if unavailable_after else None ) diff --git a/hcloud/firewalls/domain.py b/hcloud/firewalls/domain.py index 07cfadd..5390cce 100644 --- a/hcloud/firewalls/domain.py +++ b/hcloud/firewalls/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -30,7 +30,7 @@ def __init__( self.rules = rules self.applied_to = applied_to self.labels = labels - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None class FirewallRule: diff --git a/hcloud/floating_ips/domain.py b/hcloud/floating_ips/domain.py index 01fce17..ea1884e 100644 --- a/hcloud/floating_ips/domain.py +++ b/hcloud/floating_ips/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -72,7 +72,7 @@ def __init__( self.blocked = blocked self.protection = protection self.labels = labels - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.name = name diff --git a/hcloud/images/domain.py b/hcloud/images/domain.py index 6e387b6..67ca9cf 100644 --- a/hcloud/images/domain.py +++ b/hcloud/images/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain, DomainIdentityMixin @@ -85,11 +85,11 @@ def __init__( self.id = id self.name = name self.type = type - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.description = description self.image_size = image_size self.disk_size = disk_size - self.deprecated = isoparse(deprecated) if deprecated else None + self.deprecated = datetime.fromisoformat(deprecated) if deprecated else None self.bound_to = bound_to self.os_flavor = os_flavor self.os_version = os_version diff --git a/hcloud/isos/domain.py b/hcloud/isos/domain.py index 906b42d..52a9781 100644 --- a/hcloud/isos/domain.py +++ b/hcloud/isos/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain, DomainIdentityMixin @@ -36,4 +36,4 @@ def __init__( self.type = type self.architecture = architecture self.description = description - self.deprecated = isoparse(deprecated) if deprecated else None + self.deprecated = datetime.fromisoformat(deprecated) if deprecated else None diff --git a/hcloud/load_balancers/domain.py b/hcloud/load_balancers/domain.py index 0729734..c57913e 100644 --- a/hcloud/load_balancers/domain.py +++ b/hcloud/load_balancers/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -76,7 +76,7 @@ def __init__( ): self.id = id self.name = name - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.public_net = public_net self.private_net = private_net self.location = location diff --git a/hcloud/networks/domain.py b/hcloud/networks/domain.py index be203ec..a013278 100644 --- a/hcloud/networks/domain.py +++ b/hcloud/networks/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -54,7 +54,7 @@ def __init__( ): self.id = id self.name = name - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.ip_range = ip_range self.subnets = subnets self.routes = routes diff --git a/hcloud/placement_groups/domain.py b/hcloud/placement_groups/domain.py index e3ee0c6..ffc262a 100644 --- a/hcloud/placement_groups/domain.py +++ b/hcloud/placement_groups/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -35,7 +35,7 @@ def __init__( self.labels = labels self.servers = servers self.type = type - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None class CreatePlacementGroupResponse(BaseDomain): diff --git a/hcloud/primary_ips/domain.py b/hcloud/primary_ips/domain.py index e474149..7ab3989 100644 --- a/hcloud/primary_ips/domain.py +++ b/hcloud/primary_ips/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -74,7 +74,7 @@ def __init__( self.blocked = blocked self.protection = protection self.labels = labels - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.name = name self.assignee_id = assignee_id self.assignee_type = assignee_type diff --git a/hcloud/servers/domain.py b/hcloud/servers/domain.py index a2aabd3..fc7e819 100644 --- a/hcloud/servers/domain.py +++ b/hcloud/servers/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain @@ -113,7 +113,7 @@ def __init__( self.id = id self.name = name self.status = status - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.public_net = public_net self.server_type = server_type self.datacenter = datacenter diff --git a/hcloud/ssh_keys/domain.py b/hcloud/ssh_keys/domain.py index 84d89f4..d57111c 100644 --- a/hcloud/ssh_keys/domain.py +++ b/hcloud/ssh_keys/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain, DomainIdentityMixin @@ -36,4 +36,4 @@ def __init__( self.fingerprint = fingerprint self.public_key = public_key self.labels = labels - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None diff --git a/hcloud/volumes/domain.py b/hcloud/volumes/domain.py index 71abeae..b0a98a2 100644 --- a/hcloud/volumes/domain.py +++ b/hcloud/volumes/domain.py @@ -1,4 +1,4 @@ -from dateutil.parser import isoparse +from datetime import datetime from hcloud.core.domain import BaseDomain, DomainIdentityMixin @@ -66,7 +66,7 @@ def __init__( self.id = id self.name = name self.server = server - self.created = isoparse(created) if created else None + self.created = datetime.fromisoformat(created) if created else None self.location = location self.size = size self.linux_device = linux_device diff --git a/setup.py b/setup.py index d0cdbf5..bb1945d 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,6 @@ ], python_requires=">=3.7", install_requires=[ - "python-dateutil>=2.7.5", "requests>=2.20", ], extras_require={ diff --git a/tests/unit/actions/test_domain.py b/tests/unit/actions/test_domain.py index b15d04e..02959da 100644 --- a/tests/unit/actions/test_domain.py +++ b/tests/unit/actions/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.actions.domain import Action @@ -11,8 +10,8 @@ def test_started_finished_is_datetime(self): id=1, started="2016-01-30T23:50+00:00", finished="2016-03-30T23:50+00:00" ) assert action.started == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) assert action.finished == datetime.datetime( - 2016, 3, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 3, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/certificates/test_domain.py b/tests/unit/certificates/test_domain.py index 30cdee0..f2ec28d 100644 --- a/tests/unit/certificates/test_domain.py +++ b/tests/unit/certificates/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.certificates.domain import Certificate @@ -14,11 +13,11 @@ def test_created_is_datetime(self): not_valid_before="2016-01-30T23:50+00:00", ) assert certificate.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) assert certificate.not_valid_after == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) assert certificate.not_valid_before == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/core/test_domain.py b/tests/unit/core/test_domain.py index 9e71cee..09aa6ba 100644 --- a/tests/unit/core/test_domain.py +++ b/tests/unit/core/test_domain.py @@ -1,5 +1,6 @@ +from datetime import datetime + import pytest -from dateutil.parser import isoparse from hcloud.core.domain import ( BaseDomain, @@ -101,7 +102,7 @@ class ActionDomain(BaseDomain, DomainIdentityMixin): def __init__(self, id, name="name1", started=None): self.id = id self.name = name - self.started = isoparse(started) if started else None + self.started = datetime.fromisoformat(started) if started else None class TestBaseDomain: @@ -125,7 +126,7 @@ class TestBaseDomain: { "id": 4, "name": "name-name3", - "started": isoparse("2016-01-30T23:50+00:00"), + "started": datetime.fromisoformat("2016-01-30T23:50+00:00"), }, ), ], diff --git a/tests/unit/firewalls/test_domain.py b/tests/unit/firewalls/test_domain.py index 11170ad..bcbfea3 100644 --- a/tests/unit/firewalls/test_domain.py +++ b/tests/unit/firewalls/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.firewalls.domain import Firewall @@ -9,5 +8,5 @@ class TestFirewall: def test_created_is_datetime(self): firewall = Firewall(id=1, created="2016-01-30T23:50+00:00") assert firewall.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/floating_ips/test_domain.py b/tests/unit/floating_ips/test_domain.py index 293cafc..3480ba5 100644 --- a/tests/unit/floating_ips/test_domain.py +++ b/tests/unit/floating_ips/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.floating_ips.domain import FloatingIP @@ -9,5 +8,5 @@ class TestFloatingIP: def test_created_is_datetime(self): floatingIP = FloatingIP(id=1, created="2016-01-30T23:50+00:00") assert floatingIP.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/images/test_client.py b/tests/unit/images/test_client.py index 53ca544..94ef4d0 100644 --- a/tests/unit/images/test_client.py +++ b/tests/unit/images/test_client.py @@ -1,8 +1,8 @@ import datetime +from datetime import timezone from unittest import mock import pytest -from dateutil.tz import tzoffset from hcloud.actions.client import BoundAction from hcloud.images.client import BoundImage, ImagesClient @@ -26,14 +26,14 @@ def test_bound_image_init(self, image_response): assert bound_image.image_size == 2.3 assert bound_image.disk_size == 10 assert bound_image.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) assert bound_image.os_flavor == "ubuntu" assert bound_image.os_version == "16.04" assert bound_image.architecture == "x86" assert bound_image.rapid_deploy is False assert bound_image.deprecated == datetime.datetime( - 2018, 2, 28, 0, 0, tzinfo=tzoffset(None, 0) + 2018, 2, 28, 0, 0, tzinfo=timezone.utc ) assert isinstance(bound_image.created_from, BoundServer) diff --git a/tests/unit/images/test_domain.py b/tests/unit/images/test_domain.py index 939fa14..4808ff9 100644 --- a/tests/unit/images/test_domain.py +++ b/tests/unit/images/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.images.domain import Image @@ -9,5 +8,5 @@ class TestImage: def test_created_is_datetime(self): image = Image(id=1, created="2016-01-30T23:50+00:00") assert image.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/isos/test_client.py b/tests/unit/isos/test_client.py index 0550ca5..13bc242 100644 --- a/tests/unit/isos/test_client.py +++ b/tests/unit/isos/test_client.py @@ -1,8 +1,8 @@ import datetime +from datetime import timezone from unittest import mock import pytest -from dateutil.tz import tzoffset from hcloud.isos.client import BoundIso, IsosClient @@ -21,7 +21,7 @@ def test_bound_iso_init(self, iso_response): assert bound_iso.type == "public" assert bound_iso.architecture == "x86" assert bound_iso.deprecated == datetime.datetime( - 2018, 2, 28, 0, 0, tzinfo=tzoffset(None, 0) + 2018, 2, 28, 0, 0, tzinfo=timezone.utc ) diff --git a/tests/unit/isos/test_domain.py b/tests/unit/isos/test_domain.py index da1c1de..aceead5 100644 --- a/tests/unit/isos/test_domain.py +++ b/tests/unit/isos/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.isos.domain import Iso @@ -9,5 +8,5 @@ class TestIso: def test_deprecated_is_datetime(self): iso = Iso(id=1, deprecated="2016-01-30T23:50+00:00") assert iso.deprecated == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/load_balancers/test_domain.py b/tests/unit/load_balancers/test_domain.py index 2f29cce..cff4127 100644 --- a/tests/unit/load_balancers/test_domain.py +++ b/tests/unit/load_balancers/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.load_balancers.domain import LoadBalancer @@ -8,6 +7,4 @@ class TestLoadBalancers: def test_created_is_datetime(self): lb = LoadBalancer(id=1, created="2016-01-30T23:50+00:00") - assert lb.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) - ) + assert lb.created == datetime.datetime(2016, 1, 30, 23, 50, tzinfo=timezone.utc) diff --git a/tests/unit/networks/test_client.py b/tests/unit/networks/test_client.py index 5d70d99..649094f 100644 --- a/tests/unit/networks/test_client.py +++ b/tests/unit/networks/test_client.py @@ -1,7 +1,7 @@ +from datetime import datetime from unittest import mock import pytest -from dateutil.parser import isoparse from hcloud.actions.client import BoundAction from hcloud.networks.client import BoundNetwork, NetworksClient @@ -20,7 +20,9 @@ def test_bound_network_init(self, network_response): ) assert bound_network.id == 1 - assert bound_network.created == isoparse("2016-01-30T23:50:11+00:00") + assert bound_network.created == datetime.fromisoformat( + "2016-01-30T23:50:11+00:00" + ) assert bound_network.name == "mynet" assert bound_network.ip_range == "10.0.0.0/16" assert bound_network.protection["delete"] is False diff --git a/tests/unit/networks/test_domain.py b/tests/unit/networks/test_domain.py index 4740ff8..a704dfd 100644 --- a/tests/unit/networks/test_domain.py +++ b/tests/unit/networks/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.networks.domain import Network @@ -9,5 +8,5 @@ class TestNetwork: def test_created_is_datetime(self): network = Network(id=1, created="2016-01-30T23:50+00:00") assert network.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/placement_groups/test_domain.py b/tests/unit/placement_groups/test_domain.py index 7f0eba4..779304e 100644 --- a/tests/unit/placement_groups/test_domain.py +++ b/tests/unit/placement_groups/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.placement_groups.domain import PlacementGroup @@ -9,5 +8,5 @@ class TestPlacementGroup: def test_created_is_datetime(self): placement_group = PlacementGroup(id=1, created="2016-01-30T23:50+00:00") assert placement_group.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/primary_ips/test_domain.py b/tests/unit/primary_ips/test_domain.py index bf2bd6d..091ea02 100644 --- a/tests/unit/primary_ips/test_domain.py +++ b/tests/unit/primary_ips/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.primary_ips.domain import PrimaryIP @@ -9,5 +8,5 @@ class TestPrimaryIP: def test_created_is_datetime(self): primaryIP = PrimaryIP(id=1, created="2016-01-30T23:50+00:00") assert primaryIP.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/servers/test_domain.py b/tests/unit/servers/test_domain.py index 1003910..fc2bdeb 100644 --- a/tests/unit/servers/test_domain.py +++ b/tests/unit/servers/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.servers.domain import Server @@ -9,5 +8,5 @@ class TestServer: def test_created_is_datetime(self): server = Server(id=1, created="2016-01-30T23:50+00:00") assert server.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/ssh_keys/test_domain.py b/tests/unit/ssh_keys/test_domain.py index 017ffca..9bea981 100644 --- a/tests/unit/ssh_keys/test_domain.py +++ b/tests/unit/ssh_keys/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.ssh_keys.domain import SSHKey @@ -9,5 +8,5 @@ class TestSSHKey: def test_created_is_datetime(self): sshKey = SSHKey(id=1, created="2016-01-30T23:50+00:00") assert sshKey.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc ) diff --git a/tests/unit/volumes/test_client.py b/tests/unit/volumes/test_client.py index fda74f9..8065fe2 100644 --- a/tests/unit/volumes/test_client.py +++ b/tests/unit/volumes/test_client.py @@ -1,7 +1,7 @@ +from datetime import datetime from unittest import mock import pytest -from dateutil.parser import isoparse from hcloud.actions.client import BoundAction from hcloud.locations.client import BoundLocation @@ -23,7 +23,9 @@ def test_bound_volume_init(self, volume_response): ) assert bound_volume.id == 1 - assert bound_volume.created == isoparse("2016-01-30T23:50:11+00:00") + assert bound_volume.created == datetime.fromisoformat( + "2016-01-30T23:50:11+00:00" + ) assert bound_volume.name == "database-storage" assert isinstance(bound_volume.server, BoundServer) assert bound_volume.server.id == 12 diff --git a/tests/unit/volumes/test_domain.py b/tests/unit/volumes/test_domain.py index 5587e3f..4894630 100644 --- a/tests/unit/volumes/test_domain.py +++ b/tests/unit/volumes/test_domain.py @@ -1,6 +1,5 @@ import datetime - -from dateutil.tz import tzoffset +from datetime import timezone from hcloud.volumes.domain import Volume @@ -9,5 +8,5 @@ class TestVolume: def test_created_is_datetime(self): volume = Volume(id=1, created="2016-01-30T23:50+00:00") assert volume.created == datetime.datetime( - 2016, 1, 30, 23, 50, tzinfo=tzoffset(None, 0) + 2016, 1, 30, 23, 50, tzinfo=timezone.utc )