diff --git a/fs/googledrivefs/googledrivefs.py b/fs/googledrivefs/googledrivefs.py index d2dc776..9975fb8 100644 --- a/fs/googledrivefs/googledrivefs.py +++ b/fs/googledrivefs/googledrivefs.py @@ -1,4 +1,4 @@ -from datetime import datetime, timezone +from datetime import datetime, UTC from io import BytesIO, SEEK_END from logging import getLogger from os import close, remove @@ -102,7 +102,7 @@ def close(self): super().close() # close the file so that it's readable for upload if self.parsedMode.writing: # google doesn't accept the fractional second part - now = datetime.utcnow().replace(microsecond=0).isoformat() + 'Z' + now = datetime.now(tz=UTC).replace(microsecond=0, tzinfo=None).isoformat() + 'Z' uploadMetadata = {'modifiedTime': now} if self.thisMetadata is None: uploadMetadata.update( @@ -338,7 +338,7 @@ def setinfo(self, path, info): if namespace == 'details': if name == 'modified': # incoming datetimes should be utc timestamps, Google Drive expects RFC 3339 - updatedData['modifiedTime'] = epoch_to_datetime(value).replace(tzinfo=timezone.utc).isoformat() + updatedData['modifiedTime'] = epoch_to_datetime(value).replace(tzinfo=UTC).isoformat() elif namespace == 'google': if name == 'indexableText': updatedData['contentHints'] = {'indexableText': value} diff --git a/pyproject.toml b/pyproject.toml index c8ff0ff..c6d206f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,7 +57,7 @@ coverage xml line-length = 200 lint.ignore = ["ANN", "D", "DTZ", "EM102", "ERA001", "FBT002", "FIX", "G004", "I", "N", "PT009", "PT027", "PT013", "PTH", "S101", "TCH003", "TD", "TRY003", "W191"] lint.select = ["ALL"] -target-version = "py37" +target-version = "py38" [tool.ruff.lint.extend-per-file-ignores] "__init__.py" = ["F401"] diff --git a/tests/test_googledrivefs.py b/tests/test_googledrivefs.py index cc98279..820814f 100644 --- a/tests/test_googledrivefs.py +++ b/tests/test_googledrivefs.py @@ -1,4 +1,4 @@ -from datetime import datetime, timedelta, timezone +from datetime import datetime, timedelta, UTC from hashlib import md5 from io import BytesIO from json import load, loads @@ -107,7 +107,7 @@ def test_webhooks(self): self.fs.touch('touched-file.txt') - expirationDateTime = datetime.now(timezone.utc) + timedelta(minutes=5) + expirationDateTime = datetime.now(UTC) + timedelta(minutes=5) subscriptionId = str(uuid4()) self.fs.watch('touched-file.txt', tunnel.public_url.replace('http://', 'https://'), subscriptionId, expirationDateTime) info(f'Watching {subscriptionId}')