Skip to content

Commit

Permalink
review comments.
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Tripathi <rauhl.psit.ec@gmail.com>
  • Loading branch information
Rahul Tripathi committed Apr 3, 2024
1 parent 52f684a commit 44f106a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions libs/community/langchain_google_community/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ class GoogleDriveLoader(BaseLoader, BaseModel):
load_auth: bool = False
"""Whether to load authorization identities."""

def _get_identity_metadata_from_id(self, id: str):
def _get_identity_metadata_from_id(self, id: str)-> List[str]:
"""Fetch the list of people having access to ID file."""
try:
from googleapiclient.discovery import build
from googleapiclient.discovery import build # type: ignore[import]
import googleapiclient.errors # type: ignore[import]
except ImportError as exc:

Check failure on line 56 in libs/community/langchain_google_community/drive.py

View workflow job for this annotation

GitHub Actions / cd libs/community / - / make lint #3.8

Ruff (I001)

langchain_google_community/drive.py:54:1: I001 Import block is un-sorted or un-formatted
raise ImportError(
"You must run "
Expand All @@ -63,7 +64,17 @@ def _get_identity_metadata_from_id(self, id: str):
authorized_identities = []
creds = self._load_credentials()
service = build("drive", "v3", credentials=creds) # Build the service
permissions = service.permissions().list(fileId=id).execute()
try:
permissions = service.permissions().list(fileId=id).execute()
except googleapiclient.errors.HttpError:
print(f"You dont have permission to retrieve permission for the file \
with fileId: {id}")
return authorized_identities
except Exception as exc:
print(f"Error occured while fetching permission for the file with fileId: {id}")

Check failure on line 74 in libs/community/langchain_google_community/drive.py

View workflow job for this annotation

GitHub Actions / cd libs/community / (Check for spelling errors)

occured ==> occurred

Check failure on line 74 in libs/community/langchain_google_community/drive.py

View workflow job for this annotation

GitHub Actions / cd libs/community / - / make lint #3.8

Ruff (E501)

langchain_google_community/drive.py:74:89: E501 Line too long (92 > 88)
print(f"Error: {exc}")
return authorized_identities

for perm in permissions.get("permissions", {}):
email_id = (
service.permissions()
Expand Down

0 comments on commit 44f106a

Please sign in to comment.