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

Return added team membership instance #2956

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jdelic
Copy link
Contributor

@jdelic jdelic commented Apr 22, 2024

These are just small improvements.

Specifically:

  • Adding a team membership returns the same schema/data structure as getting a team membership, so we should return a Membership instance.
  • Deleting a team and removing a team membership both return HTTP 204 on success and so, like other examples in the API, these methods should return a bool to show whether they were succesful.

@jdelic jdelic force-pushed the feature/add-team-return-values branch from bebcdb4 to f5d5190 Compare April 22, 2024 11:33
@jdelic jdelic force-pushed the feature/add-team-return-values branch from f5d5190 to 20d17da Compare April 22, 2024 11:49
"DELETE",
self.url,
)
return status == 204
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is bad practise: #2760

"""
:calls: `DELETE /teams/{team_id}/memberships/{username} <https://docs.github.com/en/rest/reference/teams#remove-team-membership-for-a-user>`_
"""
assert isinstance(member, github.NamedUser.NamedUser), member
headers, data = self._requester.requestJsonAndCheck("DELETE", f"{self.url}/memberships/{member._identity}")
status, headers, data = self._requester.requestJson("DELETE", f"{self.url}/memberships/{member._identity}")
return status == 204
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here

@@ -218,6 +219,7 @@ def add_membership(self, member: NamedUser, role: Opt[str] = NotSet) -> None:
headers, data = self._requester.requestJsonAndCheck(
"PUT", f"{self.url}/memberships/{member._identity}", input=put_parameters
)
return github.Membership.Membership(self._requester, headers, data, completed=True)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Happy to approve this change, but can you extend the tests in tests/Team.py? Tests already call add_membership, so simply assert some attributes of the returned Membership instance.

@EnricoMi EnricoMi changed the title Add return values to Team operations where the API specifies a return value, but we didn't honor it so far Return added team membership instance May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants