Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaFaer committed Feb 5, 2024
1 parent c52a63e commit 4883ea2
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions dlt/common/configuration/specs/gdrive_credentials.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import re
import json
import os
from urllib.parse import urlparse, parse_qs
from typing import Any, Dict, List, Literal, Optional
Expand All @@ -12,6 +11,8 @@
from google.oauth2 import service_account
import pydata_google_auth # type: ignore

from dlt.common import json


scope_dict = {
"full_control": "https://www.googleapis.com/auth/drive",
Expand Down Expand Up @@ -128,18 +129,18 @@ def _upload_chunk(self, final: Optional[bool] = False) -> bool:
self.buffer.seek(0)
data = self.buffer.getvalue()
head = {}
l = len(data)
length = len(data)
if final and self.autocommit:
if l:
part = "%i-%i" % (self.offset, self.offset + l - 1)
head["Content-Range"] = "bytes %s/%i" % (part, self.offset + l)
if length:
part = "%i-%i" % (self.offset, self.offset + length - 1)
head["Content-Range"] = "bytes %s/%i" % (part, self.offset + length)
else:
# closing when buffer is empty
head["Content-Range"] = "bytes */%i" % self.offset
data = None
else:
head["Content-Range"] = "bytes %i-%i/*" % (self.offset, self.offset + l - 1)
head.update({"Content-Type": "application/octet-stream", "Content-Length": str(l)})
head["Content-Range"] = "bytes %i-%i/*" % (self.offset, self.offset + length - 1)
head.update({"Content-Type": "application/octet-stream", "Content-Length": str(length)})
req = self.fs.service._http.request
head, body = req(self.location, method="PUT", body=data, headers=head)
status = int(head["status"])
Expand Down Expand Up @@ -273,7 +274,7 @@ def connect(self, method: Optional[str] = None) -> None:
cred = self._connect_cache()
elif method == "anon":
cred = AnonymousCredentials()
elif method is "service_account":
elif method == "service_account":
cred = self._connect_service_account()
else:
raise ValueError(f"Invalid connection method `{method}`.")
Expand Down

0 comments on commit 4883ea2

Please sign in to comment.