Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: filter connections by entity [ENG-2523] #1200

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix: filter connections by entity
kaavee315 committed Jan 15, 2025
commit 6579900c3ef41382b7a7572cd425d5d77cdb2eb6
2 changes: 1 addition & 1 deletion python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
@@ -1360,7 +1360,7 @@ def get_connected_account(self, id: str) -> ConnectedAccountModel:
return self.client.connected_accounts.get(connection_id=id)

def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding docstring to clarify the behavior of entity filtering:

def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
    """
    Retrieve connected accounts filtered by the current entity ID.
    
    Returns:
        List[ConnectedAccountModel]: List of connected accounts for the current entity.
                                   If no entity_id is set, returns all accounts.
    """

return self.client.connected_accounts.get()
return self.client.connected_accounts.get(entity_ids=[self.entity_id] if self.entity_id else None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing None for entity_ids parameter may behave differently than omitting it entirely. Consider skipping the parameter when entity_id is None rather than passing None explicitly. Additionally, the change introduces a potential issue where 'entity_ids' could be set to None, which might not be handled by the 'get' method, leading to unexpected behavior.

📝 Committable Code Suggestion

‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
return self.client.connected_accounts.get()
return self.client.connected_accounts.get(entity_ids=[self.entity_id] if self.entity_id else None)
def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
return self.client.connected_accounts.get(entity_ids=[self.entity_id] if self.entity_id else [])


def get_entity(self, id: t.Optional[str] = None) -> Entity:
"""Get entity object for given ID."""