Skip to content

Commit

Permalink
Remove use of utcnow and timezone.utc
Browse files Browse the repository at this point in the history
  • Loading branch information
rkhwaja committed May 27, 2024
1 parent 06d5f72 commit 09a5882
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions fs/googledrivefs/googledrivefs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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, tz=None).isoformat() + 'Z'
uploadMetadata = {'modifiedTime': now}
if self.thisMetadata is None:
uploadMetadata.update(
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 2 additions & 2 deletions tests/test_googledrivefs.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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}')
Expand Down

0 comments on commit 09a5882

Please sign in to comment.