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

feat: v1 to v2 shift #1369

Closed
wants to merge 5 commits into from
Closed
Changes from 4 commits
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
4 changes: 4 additions & 0 deletions python/composio/client/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -1531,6 +1531,10 @@ def create(
def remove(self, id: str) -> None:
self.client.http.delete(url=str(self.endpoint / id))
Comment on lines 1531 to 1532
Copy link
Contributor

Choose a reason for hiding this comment

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

Removing the delete() method without providing an alternative could break backward compatibility for code that depends on getting the status code. The remove() method should return the status code or document the breaking change.

📝 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 remove(self, id: str) -> None:
self.client.http.delete(url=str(self.endpoint / id))
def remove(self, id: str) -> int:
response = self.client.http.delete(url=str(self.endpoint / id))
return response.status_code


def delete(self, id: str) -> int:
Copy link
Contributor

Choose a reason for hiding this comment

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

The new delete() method duplicates the HTTP delete call already used in remove(). Consider refactoring the common deletion logic into a helper (or have remove() delegate to delete()) to avoid duplication and potential inconsistencies. Also, clarify the intended difference between remove() (no return) and delete() (returning status code).

response = self.client.http.delete(url=str(self.endpoint / id))
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 error handling using the existing _raise_if_required method to maintain consistency with the rest of the codebase:

response = self.client.http.delete(url=str(self.endpoint / id))
self._raise_if_required(response, status_code=204)  # 204 is typical for successful DELETE
return response.status_code

Copy link
Contributor

Choose a reason for hiding this comment

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

The variable 'response' is now assigned but not used. If the response is important, consider validating its status or content; otherwise, remove the assignment.

Suggested change
response = self.client.http.delete(url=str(self.endpoint / id))
self.client.http.delete(url=str(self.endpoint / id))

return response.status_code
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicate functionality with remove() and delete() methods doing the same thing. remove() should be removed or marked as deprecated since delete() provides more functionality by returning status code.

📝 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 remove(self, id: str) -> None:
self.client.http.delete(url=str(self.endpoint / id))
def delete(self, id: str) -> int:
response = self.client.http.delete(url=str(self.endpoint / id))
return response.status_code
@deprecated("Use delete() instead as it provides status code information")
def remove(self, id: str) -> None:
self.client.http.delete(url=str(self.endpoint / id))
def delete(self, id: str) -> int:
response = self.client.http.delete(url=str(self.endpoint / id))
return response.status_code


@t.overload # type: ignore
def get(
self,
Expand Down
Loading